673 votes
0 answers
vuejs2 - Dealing with Race Conditions when making Fetch requests in Vue.js
Solution:
You are dealing with async functionsetFulfillmentData
, so you should await it, then you can removesetTimeOut
async mounted() { // It's better to use beforeMount while fetching data for component
try {
this.dataLoaded = false;
this.setCustomerZipCode()
await this.setFulfillmentData()
this.setVariantInStock()
this.dataLoaded = true;
} catch (error) {
// Handle the error
}
}
Undefined asked
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.