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

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

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 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!