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

90
Vistas
Need help displaying favourites in React/Express app

I am using React, Express and Petfinder API. I am able to successfully save each favourited pet to localStorage and would like to display the list of favourites for that logged in user, on a new page. Here is where I am adding the pet as a favourite

const addFavouritePet = (Pet) => {
    const newFavList = [...favourites, Pet];
    setFavourites(newFavList);
    setFavPet(Pet);

    const user = JSON.parse(localStorage.getItem("userID"));
    const pet = JSON.parse(localStorage.getItem("Favourites"));
    const userId = user.id;

    for (let fav of favourites) {
      Axios.post("http://localhost:3001/api/favourites", {
        pets_id: fav.id,
        users_id: userId,
        shelters_id: fav.organization_id,
        pet_details: pet,
      })
        .then((res) => {
          console.log(res);
        })
        .catch((err) => console.log(err));
    }
  };

Here's what I've written so far to try and get the list of favorite pets for that user and display it on a new page

export default function Favourites({ id }) {
  axios.get("http://localhost:3001/api/favourites").then((res) => {
    for (let i = 0; i < res.data.length; i++) {
      const petData = res.data.pet_details;
    }
  });
  return (
    <>
      <div>Favourites</div>
    </>
  );
}
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