I am trying to integrate access to dropbox within my backend code. I followed this thread: https://www.wix.com/velo/forum/coding-with-velo/dropbox-package-installation
But I am getting hung up on something very basic. Here is the top part of my https-functions.js file:
import {ok, badRequest} from 'wix-http-functions';
import wixUsers from 'wix-users-backend';
import wixData from 'wix-data';
import wixCrm from 'wix-crm-backend';
import {getSecret} from 'wix-secrets-backend';
import dropbox from 'dropbox';
import {fetch} from 'wix-fetch';
And here is a simple API to test with:
case 'deleteexpiredpendingxfers': {
let results;
try {
results = await deleteExpiredPendingTransfers();
response.body = {[RESULT_KEY]:true,"deleteexpiredpendingxfers":results.entries.length};
} catch (error) {
response.body = {[RESULT_KEY]:false};
}
return ok(response);
And finally, the function written initially not to do much except just ensure everything is wired up correctly:
async function deleteExpiredPendingTransfers() {
console.log("deleteExpiredPendingTransfers function called");
// Get a Dropbox class
let Dropbox = dropbox.Dropbox;
// Get DB access token
let token = await getSecret("dbat");
// Get folder for items
let xferfolder = "/" + await getSecret("dbpx");
// Get a dropbox object
let dbx = new Dropbox({ accessToken: token, fetch: fetch });
return dbx.filesListFolder({path: xferfolder});
}
The problem is right off the bat, I’m getting an exception thrown:
Got error in deleteexpiredpendingxfers: TypeError: Cannot read property ‘Dropbox’ of undefined
Presumably this means that the variable ‘dropbox’ that I’ve imported at the top is ‘undefined’, so when I reference it in the function like:
let Dropbox = dropbox.Dropbox;
It is throwing an error because it doesn’t recognize the variable ‘dropbox’. Why is this? I can see that my dropbox npm is installed:
Separately, when I get this error, even though my API returns a response on the client side caller (an android app), I am getting a “Timeout accessing the website” from within that app (I’m using Volley to make the https API call). I am not sure why that would be happening either, it is as if my:
return ok(response)
is not being processed at the server?