In one WIX application it works perfectly, in a second I got the error message "Cannot read property ‘Dropbox’ of undefined dropboxjsw.jsw Line 14
Cannot read property ‘Dropbox’ of undefined
I open a dropbox folder for the second application and I got the API key for it. I’m also wondering how the dropbox npm knows to which folder it has to add the file because I don’t know where the application name is coded. Therefore, I tried the API key of the first working application. I though maybe it will write on the same dropbox folder, but I got the same error.
Please help!!!
Backend dropboxjsw.jsw
import dropbox from ‘dropbox’ ;
import { fetch } from ‘wix-fetch’ ;
const access = ‘here I wrote my dropbox API key to this application’
export function addfiletodropbox ( contents , sug ) {
console . log ( “contents==>” , contents )
console . log ( “sug==>” , sug )
let Dropbox = dropbox . Dropbox ; // this is line 14 of the error message
let dbx = new Dropbox ({ accessToken : access , fetch : fetch });
var time = new Date ()
var hour = String ( time . getHours ()) + String ( time . getMinutes ())
if ( sug === “horaot” ) {
let pth = “/” + sug + hour + “.txt”
return new Promise ( function ( resolve , reject ) {
resolve (
//dbx.filesUpload( { “path”: “/hachnasot.csv” , contents })
dbx . filesUpload ({ “path” : String ( pth ), contents })
. then (( response ) => {
return response ;
})
. catch (( error ) => {
return error ;
}) ); }); } }
Client side
import { addfiletodropbox } from ‘backend/dropboxjsw’ ;
export function button3_click ( event ) {
var contents = “”
contents = BOM + “K” + “12345” + “00” + “\n”
addfiles ( contents )
async function addfiles ( contents ) {
sug = “horaot”
let response = await addfiletodropbox ( contents , sug );
console . log ( “response===>” , response )
} }