I've implemented a function in the mounted() hook to fetch files from my Dropbox account using a promise. Once the promise is resolved successfully, I iterate through all the files and execute another promise function to retrieve additional information for each file and store it in an object.
data () {
return {
results: [],
dropbox: [],
}
},
mounted() {
dropbox.filesListFolder({path: '/wallpapers'}).then(this.successHandler)
this.dropbox = dropbox
},
methods: {
successHandler (response) {
const files = response.entries;
async function processArray(files) {
for (const item of files) {
item['meta'] = await this.getFileInfo(item.id);
}
}
processArray(files);
this.results = files;
}
getFileInfo (id) {
this.dropbox.filesGetMetadata({
path: id,
})
.then(this.successFileInfo)
},
successFileInfo (response) {
return response;
}
}
However, I encountered an error message:
Cannot read property 'getFileInfo' of undefined