What are good ways/best practice for handling chains of dependent network requests.Consider the following pseudocode:Foo(){    if(Bar is valid)    {        Request(callback)    }    else    {        RequestToGetValidBar(otherCallback)    }}How would I now continue the 'RequestToGetValidBar' request? Should I implement the chain of responsibility pattern?The context:The requests call my simple API. If I want to get data in my application from an API endpoint, I need to provide a valid token. If the token is invalid, how can I interpose the request to get a valid token and then continue the initial request?
Chain/Interpose async requests
design;api;http request