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

95
Visualizações
My react app is working in browser but not in my mobile

I'm developing a react app, I want to try some functions in my mobile but when I try to connect to it, I have an error. I understand that is an asynchronus problem... I'm trying to map an (by the moment) undefined array. But I don't understand by in the browser is working well and in my mobile not.

const eventsFetch = async () => {
    const resEvents = await getAllEvents();
    const newArray = resEvents.filter((e) => {
        const date = new Date(e.date);

    return date.getTime() >= Date.now();
    });

    newArray.sort((e) => e.important === true ? -1 : 1);
    setEvents(newArray);
}

Here is an screenshot from the mobile browser.. I tried with Chrome, Safari and Brave and always I got the same error. enter image description here

By last, I already try adding the optional chaining operator to the array, but I have the same result.

EDIT: If I add a console.log with the result of the array after the filter and the sort, in my computer I can see that it's working fine. Here ah image: enter image description here

EDIT 2:

export const getAllEvents = async() => {
    try{
        const req = await fetch(getAllEventsUrl, {
            method: "GET",
            headers: {
                Accept: "application/json",
                "Content-Type": "application/json",
                "Access-Control-Allow-Origin": "*",
            },
            credentials: "include",
        });
    
        const response = await req.json();
    
        if (!req.ok) {
            const error = new Error(response)
            error.status = req.status;
            return error;
        }
        
        return response;
    } catch(error) {
        return error;
    }
};
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