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

395
Vistas
how to query api or database with axios where object value is not the same

Is there a way to query an api or database with axios where an object element value is not the same as another object element value

Example: I am trying to get all titles ("title") where the "_ref" is not the same

{
    "__v": 0,
    "_ref": "6149290b197615d32c515dab",
    "title": "First Title",
    "details": "first"

  },
  {
    "__v": 0,
    "_ref": "6149290b197615d32c515dab",
    "title": "First Title",
    "details": "second"

  },
  {
    "__v": 0,
    "_ref": "2805jkdfg763",
    "title": "Third Title",
    "details": "third"

  }
  return await axios
    .get('http://localhost/api', {
      params: {
        _ref: != _ref
      },
    })
    .then(response => {
      EventRegister.emit('MongoDb_Data', response.data);
      return response.data;
    })
    .catch(err => {
      console.log(err);
    });

desired results would be:

First Title
Third Title
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

const data = [
  {
    "__v": 0,
    "_ref": "6149290b197615d32c515dab",
    "title": "First Title",
    "details": "first"
  },
  {
    "__v": 0,
    "_ref": "6149290b197615d32c515dab",
    "title": "First Title",
    "details": "second"
  },
  {
    "__v": 0,
    "_ref": "2805jkdfg763",
    "title": "Third Title",
    "details": "third"
  }
]

const refmap = data.reduce((acc, { _ref, title }) => {
  acc[_ref] = {
    title,
  };
  return acc;
}, {});
console.log('c', Object.values(refmap));

you will get the array of desired output.

console.log('c', Object.values(refmap).map( a => a.title));  // final output
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