I am trying to fetch replies of a comment in an object. From the backend,i.e,LARAVEL I receive 1 object. But, in Vue it becomes undefined
Method
fetchReplies(commentid) {
axios
.get("/reply/" + commentid)
.then(res => {
if (res.data != null) {
console.log(res.data);
return res.data;
}
})
.catch(function(err) {
console.log(err);
});
}
OutPut
(2) [{…}, {…}] // for commentid 42
But When used this method in some other method
fetchComments() {
var boardid = this.boardid;
axios
.get("/comment/" + boardid)
.then(res => {
if (res.data != null) {
this.comments = res.data;
console.log(this.fetchReplies(42));
}
})
.catch(function(err) {
console.log(err);
});
},
OutPut
Undefined
Before a while, when i fetch in Vue, I receive 1 object containing data and one with no data. But, suddenly that object with no data disappears.