Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda