我有 Django REST 作为后端。我需要通过GET
.
问题:方法
中没有标题GET
。因此 Django 返回给我"Authentication credentials were not provided."
问题:
我哪里错了?
export function fetchCompanies(token, callback) {
const instance = axios.create({
baseURL: `${ROOT_URL}`,
headers: {
'Content-Type': 'application/json',
'Authorization': 'jwt '.concat(token)
}
// headers: `{content-type=application/json&authorization='+${jwtReady}}`
// headers: JSON.stringify(
// {'Content-Type':'application/json','Authorization': jwtReady}
// )
});
const request = instance.get('/api/companies/')
.then((res) => {
console.log(res);
callback(res);
})
.catch((err) => {
console.log(err);
callback(err.response);
});
return{
type: FETCH_COMPANIES,
payload: request
}
}
我必须安装这个东西。问题来自后端。我被能够在没有登录机制的情况下获得token
和POST
形成的误导headers
。我虽然我的配置是正确的,但实际上当来自reactjs/redux
gitter 频道的 @panigrap 再次向我提及时。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句