Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
What change need to make so that the all the api will be called in this async await stack?

I am making multiple dispatch call in the homepage

Its was something like this.

useEffect(() => {
        async function getStorageData() {
            setLoading(true);
            try {
                await dispatch(fetchProductA());
                await dispatch(fetchProductB());
                await dispatch(fetchProductC());
                await dispatch(fetchProductD());
                await dispatch(fetchProductE());
                await dispatch(fetchProductF());
             } catch (err) {
            console.log(err);
        } finally {
            setLoading(false);
        }
    }
    getStorageData();
}, []);

I am making multiple dispatch call in the homepage

The problem is that when calling the these api. I got an error when productC.

When that happen the function stop calling the remaining product D and E and throw an error. How can I make so that it will not break the api call.

Here is my api call.

export const fetchProductC = () => dispatch => {
    return axios
        .get('productsapi/getProductC', {
            headers: {
                'Content-Type': 'application/json',
            },
        })
        .then(res => {
            dispatch({
                type: FETCH_PRODUCTS_C,
                payload: res.data[0].Groups[0].Products,
                payGroup: res.data[0],
            });
        })
        .catch(err => {
            console.log('fetching new product error');
            throw err;
        });
};

The problem is that when calling the these api. I got an error when productC.

When that happen the function stop calling the remaining product D and E and throw an error. How can I make so that it will not break the api call.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!