[Vuejs]-Dealing with Race Conditions when making Fetch requests in Vue.js

0👍

You are dealing with async function setFulfillmentData, so you should await it, then you can remove setTimeOut

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
    }
}

Leave a comment