refactor(api): switch nowScores endpoint from GET query to POST JSON body
- send uids as JSON payload in frontend event loader - update /api/user/nowScores route to accept POST and parse req.json() - keep score lookup behavior unchanged
This commit is contained in:
parent
1fae8206f2
commit
9e892f6ed1
@ -48,7 +48,11 @@ const route = createBrowserRouter([
|
||||
score: e.score,
|
||||
realname: e.name,
|
||||
} as XCXMember));
|
||||
const uidScore = await fetch(`/api/user/nowScores?uids=${info.players.map(e => e.uid).join(',')}`);
|
||||
const uids = info.players.map(e => e.uid);
|
||||
const uidScore = await fetch(`/api/user/nowScores`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ uids }),
|
||||
});
|
||||
return { info, members, uidScore: new Map(Object.entries(await uidScore.json())) };
|
||||
},
|
||||
Component: EventPage,
|
||||
|
||||
@ -43,9 +43,8 @@ const server = serve({
|
||||
}
|
||||
},
|
||||
"/api/user/nowScores": {
|
||||
async GET(req) {
|
||||
const searchParams = new URL(req.url).searchParams;
|
||||
const uids = searchParams.get('uids')?.split(',') ?? [];
|
||||
async POST(req) {
|
||||
const { uids } = await req.json();
|
||||
const uidScore = await getUidScore(uids);
|
||||
return Response.json(uidScore);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user