feat: Connect the frontend to the API (#160)

This commit is contained in:
Wanjohi
2025-01-18 07:12:47 +03:00
committed by GitHub
parent dfe37a6cec
commit f480ced756
56 changed files with 2109 additions and 743 deletions

View File

@@ -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 (
<>