Skip to content

Commit

Permalink
docs: change spreading request headers to using new Headers (#1001)
Browse files Browse the repository at this point in the history
  • Loading branch information
forcia-tishii committed Jul 30, 2024
1 parent a9bc07d commit 40d51c5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/legacy/other-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const getAccessToken = () => Promise.resolve(`some special token here`)
*/

const requestMiddleware: RequestMiddleware = async (request) => {
const headers = new Headers(request.headers)
headers.set(`x-auth-token`, await getAccessToken())

return {
...request,
headers: {
...request.headers,
'x-auth-token': await getAccessToken(),
},
headers,
}
}

Expand All @@ -33,9 +33,13 @@ const getAccessToken = () => Promise.resolve(`some special token here`)

const requestMiddleware: RequestMiddleware = async (request) => {
const token = await getAccessToken()

const headers = new Headers(request.headers)
headers.set(`x-auth-token`, token)

return {
...request,
headers: { ...request.headers, 'x-auth-token': token },
headers,
}
}

Expand Down

0 comments on commit 40d51c5

Please sign in to comment.