django Postman 的请求起作用,但Angular 不起作用

0sgqnhkj  于 2022-12-20  发布在  Go
关注(0)|答案(1)|浏览(161)

enter image description here
我发送登录返回的不记名令牌,它工作正常
令牌到达但API响应
未提供身份验证凭据。

cngwdvgl

cngwdvgl1#

有同样的问题,通过传递一个普通对象到header属性来解决它!

return this.http.post('/test/hello',
        formData,
        {
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${token}`
            },
        }
    );

相关问题