UNPKG

dsx-core

Version:

The core framework of Dropbox Solutions Accelerators. This framework contains all needed functionalities to work with Dropbox APIs. It handles authentication, http requests and responses, and all needed endpoints.

18 lines (15 loc) 514 B
export async function createFileRequest(dbx, fileRequest) { const response = await dbx.fileRequestsCreate(fileRequest); const createdFileRequest = response.result; return createdFileRequest; } export async function createFileRequestBatch(dbx, fileRequests) { const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); [...fileRequests].reduce( (p, _, i) => p .then(() => delay(Math.random() * 1000)) .then(() => createFileRequest(dbx, fileRequests[i])), Promise.resolve() ); }