feat(SW-1012): Added possibility for multiple include params for hotels
This commit is contained in:
committed by
Fredrik Thorsson
parent
92bbfcf533
commit
05006506f0
@@ -30,11 +30,20 @@ const wrappedFetch = fetchRetry(fetch, {
|
||||
export async function get(
|
||||
endpoint: Endpoint,
|
||||
options: RequestOptionsWithOutBody,
|
||||
params = {}
|
||||
params: Record<string, any> = {}
|
||||
) {
|
||||
const url = new URL(env.API_BASEURL)
|
||||
url.pathname = endpoint
|
||||
url.search = new URLSearchParams(params).toString()
|
||||
const searchParams = new URLSearchParams()
|
||||
Object.entries(params).forEach(([key, value]) => {
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((val) => searchParams.append(key, val))
|
||||
} else {
|
||||
searchParams.set(key, value)
|
||||
}
|
||||
})
|
||||
|
||||
url.search = searchParams.toString()
|
||||
return wrappedFetch(
|
||||
url,
|
||||
merge.all([defaultOptions, { method: "GET" }, options])
|
||||
|
||||
Reference in New Issue
Block a user