【发布时间】:2022-10-04 18:21:32
【问题描述】:
我尝试使用nestjs在auth0 api中创建用户,但给我状态401错误 enter image description here
我的代码是:enter code here
@Post()
async create( @Headers() authorization: string, @Body() User: any) {
try {
// @ts-ignore
const response = await axios.post(process.env.AUTH0_USER_CREATE, authorization, User);
// tslint:disable-next-line:no-console
console.log( authorization, User);
return response;
} catch (error) {
// tslint:disable-next-line:no-console
console.log( error, authorization, User);
return error;
}
}
-
axios的签名不是
post(url, body, options)吗?所以你需要做axios.post(process.env.AUTH0_USER_CREATE, User, { headers: { authorization: authroization.authorization } }) -
请将错误响应格式化为代码块而不是图像。
标签: typescript nestjs auth0