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

101
Vistas
Problem while setting data from API using useState - React

This is my res.data.enquiry - object I'm getting from api call

{
        active: true
         createdAt: "2021-09-03T05:58:32.584Z"
        ID: {category: Array(1),
          Images: Array(5),
          _id:'6131b96650a4b8127f7c59c8', 
           loginMethod: 0,
           phone: '65565656', …}
          messages: (4) [{…}, {…}, {…}, {…}]
             __v: 3
            _id: "COOK000000000036"
}

My UseState where I initialized the SingleEnq as an empty object to set it with res.data.enquiry during the fetch from api. (also tried null)

const [singleEnq, setSingleEnq] = useState({});

My fetch function

 function getOneticket(userID) {
        axios
          .get(`admin/enquiry/get/one?enquiryID=${userID}`)
          .then((res) => {
            setSingleEnq(res.data.enquiry)
          })
          .catch((err) => {
            console.log(err, "error message for get one ");
          });
      }

My useState remains empty. Dont know the reason. It's not setting up the data from the api.

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