mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 16:55:37 +02:00
⭐ feat: Connect the frontend to the API (#160)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { component$, Slot } from "@builder.io/qwik";
|
||||
import Nestri from "@nestri/sdk";
|
||||
import { NavProgress } from "@nestri/ui";
|
||||
import type { DocumentHead, RequestHandler } from "@builder.io/qwik-city";
|
||||
import { component$, Slot } from "@builder.io/qwik";
|
||||
import { type DocumentHead, type RequestHandler } from "@builder.io/qwik-city";
|
||||
|
||||
export const onGet: RequestHandler = async ({ cacheControl }) => {
|
||||
// Control caching for this request for best performance and to reduce hosting costs:
|
||||
@@ -13,6 +14,21 @@ export const onGet: RequestHandler = async ({ cacheControl }) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const onRequest: RequestHandler = async ({ cookie, sharedMap }) => {
|
||||
const access = cookie.get("access_token")
|
||||
if (access) {
|
||||
const bearerToken = access.value
|
||||
|
||||
const nestriClient = new Nestri({
|
||||
bearerToken,
|
||||
baseURL: "https://api.nestri.io"
|
||||
})
|
||||
|
||||
const currentProfile = await nestriClient.users.retrieve()
|
||||
sharedMap.set("profile", currentProfile.data)
|
||||
}
|
||||
}
|
||||
|
||||
export default component$(() => {
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user