Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

394
Views
cómo consultar api o base de datos con axios donde el valor del objeto no es el mismo

¿Hay alguna manera de consultar una API o una base de datos con axios donde el valor de un elemento de objeto no es el mismo que el valor de otro elemento de objeto?

Ejemplo: estoy tratando de obtener todos los títulos ("título") donde "_ref" no es el mismo

 { "__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); });

los resultados deseados serían:

 First Title Third Title
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

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));

obtendrá la matriz de salida deseada.

 console.log('c', Object.values(refmap).map( a => a.title)); // final output
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!