I am looking for a better way to deal with asynchronous issues, currently I am using setTime out to rig race conditions but this seems like a bandage solution.
Here is an example of code I want to change
endTime = inputDuration
setTimeout(function(){ edit((err) => {
if (err) {
return res.sendStatus(500)
}
},500)});
edit function takes in the parameters "startTime, endTime, and "name". The problem is endTime is created through a function which takes in an input and transforms it. this causes a race condition which makes it so that if endTime isn't produced fast enough, edit will fire first causing an undesirable outcome.