Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda