The title is likely misleading for I'm not sure how to summarize my question in one sentence.
I have a scenario where my script has to post data to multiple URLs in parallel and I'm struggling to figure out how to visually track what's happening with each individual URL (i.e. what's being posted and what's being returned). Here is my code:
const axios = require('axios');
const postData = async (order_id) => {
for(let i = 0; i < 10; i++){
let data = await grabDataFromSomewhere(...);
await axios.post(`http://example.net/orders/${order_id}`, {data})
.then(response => {
//console.log(response.data);
console.log(i, `POSTING TO http://example.net/orders/${order_id}`);
console.log("--- Response:", response.data)
})
}
}
const orders = ['5f96499a3a19135ad163', '99a3a19135ad1630238', '6499a3a19135ad16302']
orders.forEach(id => {
postData(id)
})
The script works well in terms of posting the right data to the right URL, but the console output, obviously, is one big mess as all the axios requests finish and and dump its output to the same console.
What's the best way to keep an eye on the output of each individual call to the postData function in its own dedicated console?
For those who use screen on Linux, a good way to visualize what I'm looking for is imagining each call to postData spawning a new screen which I can attach any time and see the function's output.