This code is definitely wrong, but I'm not sure how to fix it.
E.g.
fetch('api/foo?get_max=True')
.then( function(response) {
return response.json();
}
.then( function(response) {
var max = response["max"];
}
fetch('api2/bar?max=' + max)
.then( function(response) {
return response.json();
}
.then( function(mydata) {
processdata(mydata);
}
This obviously doesn't work, because the max var that will eventually be defined in the first fetch does not yet exist when the second fetch runs. How can I "chain" or force the second fetch to "wait" for the first fetch?