Skip to content

Commit

Permalink
fix(route/xueqiu): update lib/routes/xueqiu/cookies.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
  • Loading branch information
zhoukuncheng and TonyRL committed May 1, 2024
1 parent 03c0246 commit daa6f9f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/routes/xueqiu/cookies.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import ofetch from '@/utils/ofetch';
import cache from '@/utils/cache';
import { config } from '@/config';

export const parseToken = async () => {
const res = await ofetch.raw(`https://xueqiu.com`);
const cookieArray = res.headers.getSetCookie();
return cookieArray.find((c) => c.startsWith('xq_a_token='));
};
export const parseToken = () =>
cache.tryGet(
'xueqiu:token',
async () => {
const res = await ofetch.raw(`https://xueqiu.com`);
const cookieArray = res.headers.getSetCookie();
return cookieArray.find((c) => c.startsWith('xq_a_token='));
},
config.cache.routeExpire,
false
);

0 comments on commit daa6f9f

Please sign in to comment.