I have my post request working properly but am not seeing anything on the page until I do a hard refresh. I will appreciate anyone's take on what I should do. I've been stuck on this issue for a bit. I am new to using Vue3.
Where I am fetching api data:
created() {
fetch(BASE_URL + "reviews")
.then((res) => res.json())
.then((results) => {
this.reviews = results;
});
},
My post method:
methods: {
addReview() {
console.log(this.review);
fetch(BASE_URL + "reviews", {
method: "POST",
body: JSON.stringify(this.review),
headers: {
"content-type": "application/json",
},
})
.then((res) => res.json())
.then((result) => {
if (result.details) {
const error = result.details
.map((detail) => detail.message)
.join(".");
this.error = error;
} else {
this.error = "";
this.reviews.push(result);
}
});
},