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

76
Visualizações
How to Fetch API that returning result with the same order as first parameter

Is there a way to return the result from fetch API with the same order req.body, the result return a random order


exports.bookData = async (req, res) => {
  let inputList = req.body.isbns;
  let bookData = [];
  let price = [];
  let shipping = [];
  let headers = {
    "Content-Type": "application/json",
    Authorization: "6456_46446548498465",
  };

  let url = `https://api1/${inputList}`;
 
  await fetch(url, { headers: headers })
    .then((response) => {
      if (response.ok) {
              // calculate
        return response.json();
      }
    })
    .then((json) => {
      if (json) {
        bookData.push(json);
      } 
    });
     await fetch(
      `https://api3.com/${inputList}/6465dc68-564h5466g-546f684g86/`
    )
      .then((response) => response.json())
      .then((data) => {
        console.log(data);
      });
  let result = {
    bookData,
    price,
    shipping
  };

  return res.json(result);
};

Isbns : 2935689888, 2856989845, 1156464654

output:

bookData: [ { book: [Object] } ], { price: '$11.54', link: 'https://api/2856989845', },

bookData: [ { book: [Object] } ], { price: '$15.54', link: 'https://api/2935689888', },

bookData: [ { book: [Object] } ], { price: '$05.54', link: 'https://api/1156464654', },

**output: should be **

bookData: [ { book: [Object] } ], { price: '$15.54', link: 'https://api/2935689888', },

bookData: [ { book: [Object] } ], { price: '$11.54', link: 'https://api/2856989845', },

bookData: [ { book: [Object] } ], { price: '$05.54', link: 'https://api/1156464654', },

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