I am trying to implement dropbox api on a songwriting app in React.
I am able to send user to verification and get auth token, and even redirect user back to the proper page, but I can't save the link in the database, or finish uploading the file to dropbox.
I've narrowed the problem down to this block of code in my server:
const dropboxResponse = await dbx.filesUpload({
path: `/uploads/songs/${uploadedSong.originalname}`,
contents: songFileStream
});
Here is the full error code I get when I submit a new song to upload:
Error submitting new song in Database TypeError: RequestInit: duplex option is required when sending a body.
at Object.fetch (node:internal/deps/undici/undici:11457:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///Users/leedyer/Desktop/Coding/WABS/Server/server.js:232:27
And here's the github link:
https://github.com/leerobertdyer/wabs
I've tried adding "duplex: true" in the filesUpload under contents, but it didn't work.
Here is a link to filesUpload in the javascript SDK(code line 1308): https://www.dropbox.com/developers/documentation/http/documentation#files-upload
Thank you! Will update if I find a solution...
The error was occurring because my client side code was trying to use a token that hadn't come through yet. I needed to include async language...
This involved:
I understand why this took days to figure out now lol...
If anyone stumbles across this question and needs clarification i'd be happy to try to walk through it with you and get some more experience with this.