我遇到axios返回错误的问题
cause: Error: unexpected end of file
at BrotliDecoder.zlibOnError [as onerror] (node:zlib:189:17) {
errno: -5,
code: 'Z_BUF_ERROR'
我用了这个功能,我不明白为什么,虽然我已经尝试了相同的像一个月前
export async function getCredentials(req: Request, res: Response) {
const { code } = req.query;
const params = new URLSearchParams({
client_id: process.env.CLIENT_ID as string,
client_secret: process.env.CLIENT_SECRET as string,
grant_type: "authorization_code",
code: code as string,
redirect_uri: "http://localhost:3000/api/callback",
});
const response = await axios.post(
"https://discord.com/api/oauth2/token",
params,
{
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
}
);
res.json(await response.data);
}
谢谢大家!
1条答案
按热度按时间kb5ga3dv1#
很抱歉给您带来不便,解决方案是接受编码