Getting a List of Files Using the Dropbox API Chapter 4
We now need to add the ability for the component to get the directory list. For this, we are
going to create another method that takes a single parameter—the path. This will give us
the ability later to request the structure of a different path or folder if required.
Use the code provided earlier - changing the dbx variable to this.dropbox():
getFolderStructure(path) {
this.dropbox().filesListFolder({path: path})
.then(response => {
console.log(response.entries);
})
.catch(error => {
console.log(error);
});
}
Update the Dropbox filesListFolder function to accept the path parameter passed in,
rather than a fixed value. Running this app in the browser will show the Dropbox heading,
but won't retrieve any folders because the methods have not been called yet.
The Vue life cycle hooks
This is where the created() function comes in. The created() function gets called once
the Vue instance has initialized the data and methods, but has yet to mount the instance on
the HTML component. There are several other functions available at various points in the
life cycle; more about these can be read at Alligator.io. The life cycle is as follows: