Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

396
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda