Because of my backend I need to wait 3 seconds before I'll make a fetchSyncedProductsResultRequest request. I was trying to use setInterval function but it won't work:
imports.js
const importSpreadsheetRequest = (self, payload, onSuccessCb, onErrorCb) => {
const jwtToken = self.$store.state.idToken;
return axios
.post(`/api/v1/imports/products_batches/spreadsheet_load`, payload, {
headers: {
Authorization: `Bearer ${jwtToken}`,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
.then((response) => onSuccessCb(response.data))
.catch((error) => onErrorCb(error))
};
sync_products.rb
watch: {
loadId(newValue, oldValue) {
if (!oldValue && newValue) {
setTimeout(3000)
fetchSyncedProductsResultRequest(this, newValue).then(response => {
this.fetchedProductSyncResult = response.data
});
}
}
},
How to wait 3 seconds before making this call ?
[EDIT]
here is my updated code:
watch: {
loadId(newValue, oldValue) {
if (!oldValue && newValue) {
setTimeout(
fetchSyncedProductsResultRequest(this, newValue).then(response => {
this.fetchedProductSyncResult = response.data['results']
}), 3000)
}
}
},