How do I save the JWT response from an API to local-storage for later use to attach in other API calls from the page?

How do I save the JWT response from an API to local storage for later use to attach in other API calls from the page?

Question from sampushstack on Discord.

Answer posted by @sharat87

You can use the storeValue function inside the success callback of the API that gives the JWT response. So, if your AuthAPI is the API action that responds with the JWT, you could have the button that calls this API run an onClick action like the following:

{{AuthAPI.run(() => storeValue("jwt", AuthAPI.data.jwt))

After that, it can be used elsewhere and in other API actions as appsmith.store.jwt .

We also have a guide for custom auth, do check our docs here: