JSORM the isomorphic, framework-agnostic Javascript ORM
Authentication
JSORM supports JSON Web Tokens. These can
be set manually, or automatically fetched from localStorage
.
To set manually:
All requests will now send the header:
Authorization: Token token="myt0k3n"
.
To set via localStorage
, simply store the token with a key of jwt
and it will be set automatically. To customize the localStorage
key:
…or to opt-out of localStorage
altogether:
You can control the format of the header that is sent to the server:
Typescript
Javascript
Finally, if your server returns a refreshed JWT within the X-JWT
header, it will be used in all subsequent requests (and localStorage
will be updated automatically if you’re using it).