acacode / acacode/swagger-typescript-api

Requests are sent before auth header is set

未关闭
#537 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
4.1k
派生
436
PR 合并指标
30 天内没有已合并 PR

描述

I'm using this library and using react query around it. I've noticed that there is no way to check if the security data has been set so the requests are called before the auth header is set, resulting in a lot of forbidden requests. Is there something im missing or how can i fix this?

example of useEffect where i'm setting security data when token has been updated on useUser
```typescript
useEffect(() => {
if (user.token) {
API.setSecurityData({ token: user.token })
} else {
API.setSecurityData(null)
}
}, [user])
```

example of request that fire too early
```typescript
const userInfoQuery = useQuery(
["USER_INFO", user.token],
() => API.user.selfList(),
{
enabled: !!user.token,
}
)
```

i wish i could set enabled: to something else like `API.securityDataIsSet` but as far as i can see i can't even await for the securityData function to finish.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。