How to gracefully handle HTTP responses indicating I need to refresh a token

Yes. Take a look at Task.andThen and Task.onError (since your 403 is coming through on the error branch). You could chain together the initial put with the “refresh and resubmit” chain I did above, if the initial put results in a 403, and then you could do it all within one Cmd (one update cycle). Not sure if the resulting code is any clearer, but with helper functions it wouldn’t be too bad.

1 Like