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

174
Vistas
How do I restructure an API response?

Here is my back end route, is there something obvious that im missing when it comes to the returned data? I'm more experience with array manipulation, so when dealing with objects rather than forcing it into an array after returning data, how can I restructure this to return an array?

router.get('/caseDetail/:caseName', (req,res) => {
    db.caseDetail.findAll({
        
        include : [db.Part,db.Fault,db.Disposition,db.Contact,db.Site],
        where : {
            caseName:{ 
              [Op.like]: [req.params.caseName]}
        }
    }).then((response) => {
        console.log(response);
        res.json(response)
    }).catch((error) => {
        console.log(error);
    })
})

Currently I'm returning an Object rather than an array of objects, which is what im looking for, enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

you forget to use return in res.json(response)

try return res.json(response)

about 4 years ago · Juan Pablo Isaza Denunciar

0

The issue here was a syntax error on my front end route, After changing

let items = await axios.get(`/api/caseDetail/:${caseName}`);


to

let items = await axios.get(`/api/caseDetail/${caseName}`);

Everything fell into place and my use of [Op.like] worked like a charm. Thank you all for the help!

about 4 years ago · Juan Pablo Isaza Denunciar
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