You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file exports an `authFetch` function that can be used just like the normal [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) and will redirect to the login page if the user needs to log in.
18
22
19
23
## Usage
20
24
21
25
A React component using this function and loading the message from one of the [platform example servers](../platforms/index.md) can look like this:
In your Svelte application, create a `src/auth.ts` file that allows to make authenticated requests to the backend like this:
14
14
15
-
<<< @/examples/frontend/svelte/src/auth.ts
15
+
::CodePreview
16
+
---
17
+
path: frontend/svelte/src/auth.ts
18
+
---
19
+
::
16
20
17
21
This file exports an `authFetch` function that can be used just like the normal [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) and will redirect to the login page if the user needs to log in.
18
22
19
23
## Usage
20
24
21
25
A Svelte component using the Auth client and loading the message from one of the [platform example servers](../platforms/index.md) looks like this:
22
26
23
-
<<< @/examples/frontend/svelte/src/App.svelte
27
+
::CodePreview
28
+
---
29
+
path: frontend/svelte/src/App.svelte
30
+
---
31
+
::
24
32
25
33
You can find the full Vite + Svelte example application [here](https://github.com/feathersdev/examples/tree/main/client/svelte).
In any web application, create an `auth.ts` file that allows to make authenticated requests to the backend like this:
14
14
15
-
<<< @/examples/frontend/auth.ts
15
+
::CodePreview
16
+
---
17
+
path: frontend/auth.ts
18
+
---
19
+
::
16
20
17
21
This file exports an `authFetch` function that can be used just like the normal [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) and will redirect to the login page if the user needs to log in.
In your VueJS application, create a `src/auth.ts` file that allows to make authenticated requests to the backend like this:
14
14
15
-
<<< @/examples/frontend/react/src/auth.ts
15
+
::CodePreview
16
+
---
17
+
path: frontend/vue/src/auth.ts
18
+
---
19
+
::
16
20
17
21
This file exports an `authFetch` function that can be used just like the normal [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) and will redirect to the login page if the user needs to log in.
18
22
19
23
## Usage
20
24
21
25
A VueJS component using this function to load the message from one of the [platform example servers](../platforms/index.md) looks like this:
22
26
23
-
<<< @/examples/frontend/vue/src/App.vue
27
+
::CodePreview
28
+
---
29
+
path: frontend/vue/src/App.vue
30
+
---
31
+
::
24
32
25
33
You can find the full Vite + Vue example application [here](https://github.com/feathersdev/examples/tree/main/client/vue).
Then implement an HTTP handler with basic CORS [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) (necessary to allow requests from any [client framework](../client/index.md)) in `src/app.ts` like this:
22
26
23
-
<<< @/examples/server/nodejs/src/server.ts{js}
27
+
::CodePreview
28
+
---
29
+
path: server/nodejs/src/server.ts
30
+
---
31
+
::
24
32
25
33
The full NodeJS example server can be found [here](https://github.com/feathersdev/examples/tree/main/server/nodejs).
0 commit comments