I'm trying to get a video title from a axios GET to a video API:
// METHOD GETTING A VIDEO ID:
latestVideo(videoID) {
var self = this;
var title;
axios.get('http://video-api.dev/'+videoID)
.then(response => {
this.title = response.data.title
console.log(response.data.title) //returns the correct title
})
return title // returns nothing
}
Console log shows the title, but I need to pass this to outside the call function, to have it available in my Vue app.
I've tried declaring var self=this
but it does not seem to have any effect. Have I missed something?