Erudaki Erudaki - 1 month ago 7x
HTTP Question

.then handler being invoked out of order

My ultimate goal is to assign a chunk of database to class based object. To do this I am utilizing promises in typescript with the help of the

function to chain them. However I am running into brick walls.

return(, somepayload, someheaders)
.then(response => response.json())

However when this code executes the
before it gets the
which is causing issues in my program.

My question is, why are they occurring in that order and is there any way I can force them to execute in sequence?


You're calling MyCustomClass.function(MyObject), and passing the returned value to then(). What you actually want is to pass a function that, when called, will execute MyCustomClass.function(MyObject):

.then(() => {