With an API I need to make an "authentication" request to get a token then I need to make the "data" request that will return what I actually need, then I need to make a "logout" request. All completely obnoxious I know. I am trying to convert it all to asynchronous programming through the use of promises. Obviously those 3 requests need to be made in order. The solution I first came up with is nesting promises so login.then(token => { getData().then(data => {}) }) and so on. This feels really dirty like I shouldn't be doing it. Is there a better solution or am I on the right track?
Submitted August 23, 2019 at 03:42AM by Stripestar
No comments:
Post a Comment