0
I would like to know the best way to make a row of Promises in Javascript, so that the incoming Promise only runs after the previous Promise resolution.
Example:
var queue = [Promise1, Promise2];
queue.push(Promise3);
In that case I need Promise2
await the execution of Promise1
and the Promise3
await the execution of Promise2
to be executed.
In reality I need to queue to save data in a request and if I do not save in the order that the request was made the data get messy because one result depends on the answer of the other.
If you can help me I’d be grateful!
I’ll try to explain it better.
I launch a request to create a record with a note...but this record consists of 4 notes in total...the next note for this record is an update...what happens is that the release of notes can be so fast that when sending the request to create the record not from time to receive the created id so that the next one is an update, this way I end up with two records created which should be a create and then an update.
If a Promise depends on the result of the previous one, how can you instantiate it without the result you need? Because it depends on the outcome of the previous one, in my view you could only instantiate it at the moment Promise earlier had already resolved.
– Woss
And you can’t send the 4 notes in the same request?
– Woss
Unfortunately I only have the front to work, I do not have access to change the back functioning.
– Rafael Zulianeli