¿Hay alguna manera de devolver el resultado de fetch API con el mismo pedido req.body , el resultado devuelve un pedido aleatorio?
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); };ISBN: 2935689888, 2856989845, 1156464654
producción:
bookData: [ { libro: [Objeto] } ], { precio: '$11.54', enlace: 'https://api/2856989845', },
bookData: [ { libro: [Objeto] } ], { precio: '$15.54', enlace: 'https://api/2935689888', },
bookData: [ { libro: [Objeto] } ], { precio: '$05.54', enlace: 'https://api/1156464654', },
**salida: debe ser **
bookData: [ { libro: [Objeto] } ], { precio: '$15.54', enlace: 'https://api/2935689888', },
bookData: [ { libro: [Objeto] } ], { precio: '$11.54', enlace: 'https://api/2856989845', },
bookData: [ { libro: [Objeto] } ], { precio: '$05.54', enlace: 'https://api/1156464654', },