Welcome to the new Box Support website. Check out all the details here on what’s changed.

Box SDK with node.js

New post

Comments

1 comment

  • mwiller

    Hi  — I'm Matt, one of the members of the Box SDK Team!  Our team builds and maintains the Box Node SDK, and I can try and give you some general pointers to help you figure out what's going wrong in your code.

     

    First, you seem to be mixing different patterns for handling async work — that actually isn't necessary with the Node SDK!  All the SDK methods return Promises, so you could use those in order to simplify your logic a bit and make the overall flow easier to follow.  That might help make things a bit clearer and allow you to more easily trace execution of your code to find any potential issues.

     

    Next, I can spot a few issues that might be tripping you up — hopefully I can point you in the right direction!

    • Depending on how quickly the code is reading CSV rows, you may be running into rate limits from the API — the code is potentially making 4 API calls per row in the CSV, which means a total of 2,000 API calls.  The Box API documentation indicates that the current limits are 10 calls per second and specifically 4 uploads per second; if you're exceeding those the Box Node SDK will automatically attempt to retry after waiting for a period of time, which could cause perceptible delays.
    • As written, the `foundfolder()` method will only work for folders with less than 100 items in them.  If you're dealing with more items than that you may want to either increase the limit option to a higher value or ensure you're paging through the result set to get all folder items rather than just the first 100.
    • The code is calling `client.collaborations.delete()` with incorrect arguments — it just takes a Collaboration ID (see https://github.com/box/box-node-sdk/blob/master/docs/collaborations.md#remove-a-collaboration for more information)
    • In the Existing Folder case, the code is effectively calling `foundcollab()` and `client.collaborations.createWithUserEmail()` in parallel, when it looks like they should maybe be sequential.  You may want to check to ensure that the asynchronous order of the logic is correct (which may be easier if you convert everything to using Promises throughout)

    I hope that helps!

     

     

    0
    Comment actions Permalink

Please sign in to leave a comment.