[Vuejs]-Vue-resource returning a PromiseObj

5👍

Promise result values are supposed to be consumed using the then method:

response.text().then(console.log)

You can simplify your code by returning that promise and chaining onto it:

this.$http.post(endpoint, data, []).then(response => {
    console.log(response.status);
    return response.text();
}, response => {
    console.log(response.status);
    return response.json();
}).then(result => {
    console.log(result);
})
👤Bergi

Leave a comment