Getting a List of Files Using the Dropbox API Chapter 4
Viewing the app in the browser should show the heading from the template. The next step
is to integrate the Dropbox API into the component.
Retrieve the Dropbox data
Create a new method called dropbox. In there, move the code that calls the Dropbox class
and returns the instance. This will now give us access to the Dropbox API through the
component by calling this.dropbox():
Vue.component('dropbox-viewer', {
template: '#dropbox-viewer-template',
methods: {
dropbox() {
return new Dropbox({
accessToken: this.accessToken
});
}
}
});
We are also going to integrate our API key into the component. Create a data function that
returns an object containing your access token. Update the Dropbox method to use the local
version of the key:
Vue.component('dropbox-viewer', {
template: '#dropbox-viewer-template',
data() {
return {
accessToken: 'XXXX'
}
},
methods: {
dropbox() {
return new Dropbox({
accessToken: this.accessToken
});
}
}
});