Skip to content
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

🧐[问题 | question] 如何在requestErrorConfig.ts 中requestInterceptors取出保存在currentUser中的token? #11398

Open
mendellin opened this issue Nov 27, 2024 · 0 comments

Comments

@mendellin
Copy link

🧐 问题描述 | Problem description

💻 示例代码 | Sample code

在User\Login\index.tsx,用户登录成功后,保存数据到currentUser
//保存用户等信息
if (msg) {
flushSync(() => {
setInitialState((s) => ({
...s,
currentUser: msg.data,

        }));
      });
    }

currentUser 的定义
declare namespace API {
type CurrentUser = {
user_id?: number;
owner_id?:number;
username?:string;
fullname?: string;

**access_token?:string;**

is_admin?:number;
role_id?:number;


avatar?: string;
email?: string;
signature?: string;
title?: string;
group?: string;
tags?: { key?: string; label?: string }[];
notifyCount?: number;
unreadCount?: number;
country?: string;
access?: string;

geographic?: {
  province?: { label?: string; key?: string };
  city?: { label?: string; key?: string };
};
address?: string;
phone?: string;

};

在requestErrorConfig.ts中的requestInterceptors里面如何取出这个currentUser 里面的access_token并加到headers中去? 考虑到安全性,不使用localStorage

🚑 其他信息 | Other information

OS:

Node:

浏览器 | browser:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant