I'm using axios to make a get request to embed.rocks. Inorder to have the axios get request to embed.rock work I have to wrap it in a setTimeout function:
loadLink: function() {
this.status = "Loading...";
this.show = true;
setTimeout(function() {
var axios2 = axios.create();
delete axios2.defaults.headers.common['X-CSRF-TOKEN'];
delete axios2.defaults.headers.common['X-Requested-With'];
axios2({
method: 'get',
url: 'https://api.embed.rocks/api?url=' + this.url,
headers: {
'x-api-key': 'my-key'
}
})
.then(function(response) {
console.log(response);
app.url = response.data.url;
this.title = response.data.title;
this.description = response.data.description;
if (app.post_type === "video") {
this.thumbnail = response.data.oembed.thumbnail_url;
}
if (app.post_type === "article") {
this.thumbnail = response.data.images[0].url;
}
app.submitted = '';
})
.catch(function(error) {
app.status = "There was an error" + error;
});
}.bind(this))
}
As you can see when I get the response from embed.rocks I am trying to update these data properties:
data() {
return {
submitted: false,
thumbnail: '',
title: '',
description: '',
}
},
I get the response logged out in the console, but the data properties won't set. How do I set those data properties in a timed out request?
Edit I forgot to add that this is all being done in a component.