I have a function that should do a few things simultaneously. For that I call to other functions that return a Promise, like so:
async function do_things(params){
return new Promise((resolve,reject)=>{
const first_promise=perform_first(params);
const second_promise=perform_second(params);
let [first_result,second_result]=await Promise.all([first_promise,second_promise]);
...
resolve();
});
}
That should pretty much do the trick. Now I want to add .then(res) and .catch(err) blocks to log both 'res' and 'err'.
Should I do that on do_first(params).then((res)=>{...}).catch((err)=>{...});
or on first_result.then((res)=>{...}).catch((err)=>{...});
?
(obviously the second can be done likewise)