Либо использовать async/await
const myArray = ["1", "2", "3", "4"];
(async function (array) {
for (item of array) {
await fetch(`https://jsonplaceholder.typicode.com/posts/${item}`)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((error) => console.error(error));
}
})(myArray);
Либо reduce
const myArray = ["1", "2", "3", "4"];
myArray.reduce((p, item) => {
return p
.then(() => fetch(`https://jsonplaceholder.typicode.com/posts/${item}`))
.then((response) => response.json())
.then((response) => console.log(response))
.catch((error) => console.error(error));
}, Promise.resolve());