how do i move to the next action when the result of an asynchronous operation is obtained with javascript? [duplicate]

enter image description here
Usually x is null. But i need this result. how do i solve this?

I was planning to create a new record with the id information of the result and reach a result again with the new record. I usually get null results.