Skip to content

Commit

Permalink
fix: ajout du header authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
remy-auricoste committed Nov 14, 2023
1 parent 99bf29d commit 0444ee2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ui/utils/api.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ async function optionsToFetchParams(method: RequestInit["method"], options: IReq
const { timeout, headers: addedHeaders } = fetchOptions

const headers = await getHeaders(options)
const accessToken = getAccessToken()
if (accessToken) {
headers.append("authorization", `bearer ${accessToken}`)
}
if (addedHeaders) {
Object.entries(addedHeaders).forEach(([key, value]) => {
headers.append(key, value)
})
}
const accessToken = getAccessToken()
if (accessToken && !headers.has("authorization")) {
headers.append("authorization", `bearer ${accessToken}`)
}

let body: BodyInit | undefined = undefined
if ("body" in options && method !== "GET") {
Expand Down

0 comments on commit 0444ee2

Please sign in to comment.