Skip to content

Fix misquote request in middleware-auth.md #1751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/zh/openapi-fetch/middleware-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ import type { paths } from "./my-openapi-3-schema"; // 由openapi-typescript生
let accessToken: string | undefined = undefined;

const authMiddleware: Middleware = {
async onRequest(req) {
async onRequest({ request }) {
// 获取令牌,如果不存在
if (!accessToken) {
const authRes = await someAuthFunc();
Expand All @@ -137,8 +137,8 @@ const authMiddleware: Middleware = {
// (可选) 在此添加逻辑以在令牌过期时刷新令牌

// 在每个请求中添加 Authorization 标头
req.headers.set("Authorization", `Bearer ${accessToken}`);
return req;
request.headers.set("Authorization", `Bearer ${accessToken}`);
return request;
},
};

Expand Down