0👍
✅
your problem is that the ${localStorage.getItem(‘accessToken’) is evaluated just once, when the myApi is imported the first time, and presumably you still don’t have the correct accessToken stored in localStorage
if you stop and reload the app, then it will read the accessToken from the previous execution and that may work (depending on the expiration period of the token)
you need to change your logic a bit so that you read and set the token in the headers when you are actually making the subsequent calls to the chat endpoint
Source:stackexchange.com