You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Beatso's avatar
Beatso
Explorer | Level 4
5 years ago

Create sharing link after file upload

I'm using the Javascript SDK, and code uploads some files, creating their parent folders, then creates a sharing link of one of the parent folders. But because javascript is asyncronous, the files haven't been uploaded, hence creating the folder, so creating the sharing link returns a path not found error. How can I get around this problem?

  • The calls in the JavaScript SDK are asynchronous as you mentioned, so if you have additional operation(s) to perform that depend on the result of an earlier call, you should only perform the additional operation(s) once the necessary earlier ones have completed. You can do so by only triggering the later operations once you get the response back from the earlier one. 

     

    With the Dropbox JavaScript SDK, you can run code from inside the response function for an API call. So, in this example for instance, that would mean you trigger the next API call from inside the "function(response)" set in the ".then", like how that example appends a message to an element on the page.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The calls in the JavaScript SDK are asynchronous as you mentioned, so if you have additional operation(s) to perform that depend on the result of an earlier call, you should only perform the additional operation(s) once the necessary earlier ones have completed. You can do so by only triggering the later operations once you get the response back from the earlier one. 

     

    With the Dropbox JavaScript SDK, you can run code from inside the response function for an API call. So, in this example for instance, that would mean you trigger the next API call from inside the "function(response)" set in the ".then", like how that example appends a message to an element on the page.