I have Django REST as a backend. And I need to query the database over GET
.
Problem:
Header does not in the GET
method. Therefore Django returns me the
"Authentication credentials were not provided."
Question:
Where am I wrong?
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
}
}
References:
https://github.com/axios/axios#axiosgeturl-config