I’m struggling to find a way to upload a file to Dropbox using JS, fetch, etc…
Since, I didn’t success so far, I tried just to get a list of files from my Dropbox drive, but I continue getting the following error.
invalid json response body at https://content.dropboxapi.com/2/files/file_requests/list_v2 reason: Unexpected token U in JSON at position 0
It will be great if somebody could tell me what I’m doing wrong. Below is my backend JSW code.
import { fetch } from ‘wix-fetch’ ;
export function xdrop() {
const url = "https://content.dropboxapi.com/2/files/file_requests/list_v2 "
const headers = {
“Authorization” : "Bearer " + 'my token code string I got from dropbox ’ ,
“Content-Type” : “application/json” ,
}
const request = {
“method” : “post” ,
“headers” : headers,
“autorename” : true ,
“mute” : false ,
“data” : “{"limit": 1000}”
}
return fetch(url, request)
.then(response => response.json());
}
You will need to check with Dropbox regarding the requirements and behavior their API.
You might consider using the Dropbox NPM library installed via the Corvid Package Manager :