I think this what you are looking for.
I have changed your fake API for a real one, so you can test.
const axios = require('axios');
const id = ['234','9887']
const promArr = id.map(
id =>
axios.get(
`https://postman-echo.com/get?key=${1234}`,
{
method: 'GET',
headers:{'xxxxxxxxxx': 'xxxxxxxxxxx',}
}
)
)
Promise.all(promArr)
.then(function (responses) {
// handle success
responses.map(response => console.log(response.data))
})
.catch(function (error) {
// handle error
console.log(error);
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…