extended JS and TS template with Bearer token

This commit is contained in:
2026-03-30 23:32:38 +02:00
parent 394a85ef45
commit c758dc9317
4 changed files with 130 additions and 4 deletions

View File

@ -238,11 +238,15 @@ You can also download generated frontend clients:
* JavaScript: `?format=javascript`
* TypeScript (typed for Vue/TS projects): `?format=typescript`
Both generated clients support a shared Bearer token helper. Call `bearerSet(token)` once, the token is stored in `localStorage` under `apilite_bearer_token`, and subsequent requests automatically send `Authorization: Bearer ...`.
JavaScript usage example:
```js
import backend from './backend.js';
backend.bearerSet('your-access-token');
backend.add(1, 2).then((response) => {
console.log(response.data);
});
@ -253,6 +257,8 @@ TypeScript usage example (Vue + TS):
```ts
import backend from './backend';
backend.bearerSet('your-access-token');
backend.add(1, 2).then((response) => {
console.log(response.data); // typed value based on PHP return type
});