Failed to fetch the Query on reload

Viewed 56

The data from the Query does load once it loaded but once i reload it the data does not appear... I have console.log the data by using "console.log(data.allPetInformations)" and it does work and getting an array of objects...

import { ALL_PET_INFORMATIONS } from '../../../query';
import { useQuery } from '@apollo/client';
import Session from 'react-session-api';

export function ClientPet(){
    const username = Session.get('username');
    
    const { loading, error, data } = useQuery(ALL_PET_INFORMATIONS);


    if(loading) return <div>loading...</div>
    if(error) return <div>{error.message}</div>
    return(
        <div>
            {data.allPetInformations.filter(pet => pet.client.username===username).map(pet => (
                <div key={pet.id}>
                    {pet.name}
                </div>
            ))}
        </div>
    )
}
0 Answers
Related