feat: enhance stays with api data

This commit is contained in:
Christel Westerberg
2024-05-08 14:56:39 +02:00
parent 57fd59ebe2
commit 661a8019d3
18 changed files with 223 additions and 108 deletions

View File

@@ -5,6 +5,10 @@ export namespace endpoints {
export const enum v0 {
profile = "profile/v0/Profile",
}
export const enum v1 {
upcomingStays = "booking/v1/Stays/future",
previousStays = "booking/v1/Stays/past",
}
}
export type Endpoint = endpoints.v0
export type Endpoint = endpoints.v0 | endpoints.v1

View File

@@ -20,10 +20,14 @@ const defaultOptions: RequestInit = {
export async function get(
endpoint: Endpoint,
options: RequestOptionsWithOutBody
options: RequestOptionsWithOutBody,
params?: URLSearchParams
) {
defaultOptions.method = "GET"
return fetch(`${env.API_BASEURL}/${endpoint}`, merge(defaultOptions, options))
const url = new URL(
`${env.API_BASEURL}/${endpoint}${params ? `?${params.toString()}` : ""}`
)
return fetch(url, merge(defaultOptions, options))
}
export async function patch(