After sending a post request to the database, I need to refresh my cardData
array which gets its value from a get request in order to see the changes. The current saveDraft()
function adds values to the cardData
array, but it requires a page refresh or clicking twice to reflect the updates. Is there a way to dynamically update the data without refreshing the page?
saveDraft() {
Api.createComment({
// this is a post request
})
.then(res => {
if (response.status == 200) {
Api.getComments().then(res => {
// this is a get request to update the cardData
if (res.status === 200) {
this.cardData = res.data;
} else {
// handle error
}
});
} else {
// handle error
}
});
},