3👍
✅
You have a scope-problem – wrong this
:
let vm = this;
async function processArray(files) {
for (const item of files) {
item['meta'] = await vm.getFileInfo(item.id);
}
}
Or you can do:
processArray.bind(this)(files);
UPD (from comments):
You forgot return in getFileInfo
-method
getFileInfo (id) {
return this.dropbox.filesGetMetadata({
path: id,
})
.then(this.successFileInfo)
}
1👍
When you call item['meta'] = await this.getFileInfo(item.id);
, this
refers to the scope of the processArray
function and not the vue component.
If I’m not mistaken, you should just be able to do:
async successHandler (response) {
const files = response.entries;
for (const item of files) {
item['meta'] = await this.getFileInfo(item.id);
}
processArray(files);
this.results = files;
}
Source:stackexchange.com