Having trouble with a puzzling issue and unable to find any solutions online. I am attempting to make a basic HTTP get request to receive a JSON object from an API I created (using express+CORS).
I have experimented with both Axios and VueResource, yet encountered the same problem where the browser indicates that the request was successful (and even displays the expected data).
https://i.sstatic.net/8e4l6.png
However, I do not receive any responses within the promise. Despite implementing console.logs and breakpoints, it appears that the .then and .catch functions are never executed.
methods: {
getTasks() {
return this.$http.get("http://localhost:3080/api/tasks").then(response => function() {
console.log("in"); // This console.log is never run
this.data = response.data; // this.data is still null
}).catch(err => {
// No errors are returned
console.log(err);
});
}
},
mounted() {
this.getTasks();
}