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

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