I have the REST Api and response looks like this:
{
"wordText" : "hello",
"transcription" : "[həˈloʊ]",
"pronunciation" : null,
"picture" : null,
"_links" : {
"self" : {
"href" : "http://localhost:8081/api/words/1"
},
"word" : {
"href" : "http://localhost:8081/api/words/1"
},
"examples" : {
"href" : "http://localhost:8081/api/words/1/examples"
},
"translates" : {
"href" : "http://localhost:8081/api/words/1/translates"
},
"wordSet" : {
"href" : "http://localhost:8081/api/words/1/wordSet"
}
}
}
And I want to get word and after that to load translates using link in body. My current code:
let wordlist = [];
Vue.axios.get('/wordsets/1/words').then(response => {
return response.data._embedded.words;
}).then(words => {
words.map(word => {
wordlist.push(word)
})
//commit('LOAD_WORD_LIST', words);
})
wordlist.map(word => {
Vue.axios.get(word._links.translates.href).then(response => {
word.translates = response.data._embedded.translates;
return word;
})
})
console.log(wordlist);
But wordlist
doesn't changed... Also I tried to execute another axios call in then()
function, but the word.translates
is underfind