Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1

Navigating through the File Tree and Loading Folders from the URL Chapter 5


props: {
path: String
},
data() {
return {
accessToken: 'XXXX',
structure: {},
isLoading: true
}
},
methods: {
dropbox() {
return new Dropbox({
accessToken: this.accessToken
});
},
getFolderStructure(path) {
this.dropbox().filesListFolder({
path: path,
include_media_info: true
})
.then(response => {
const structure = {
folders: [],
files: []
}
for (let entry of response.entries) {
// Check ".tag" prop for type
if(entry['.tag'] == 'folder') {
structure.folders.push(entry);
} else {
structure.files.push(entry);
}
}
this.structure = structure;
this.isLoading = false;
})
.catch(error => {
this.isLoading = 'error';
console.log(error);
});
},
updateStructure(path) {
this.isLoading = true;
this.getFolderStructure(path);
}
},
created() {
Free download pdf