Closed tagmetag closed 6 years ago
Evidently, your Headers were not sent with the request and that is why you receive:
{"detail":"Authentication credentials were not provided."}
I recommend using an axiosInstance with common information like baseURL (your API URL) and headers.
import axios from 'axios';
const axiosInstance = axios.create({
baseURL: process.env.REACT_APP_BACKEND_HOST,
headers: { Authorization: `Bearer ${this.$store.state.token}` },
});
export default axiosInstance;
Then, you could call it as follows:
axiosInstance({ method, url, data, headers })
Thank you. It works perfectly.
I get this error when I use axios to POST data, respond: {"detail":"Authentication credentials were not provided."}. Please help me show the error: My VUEJS Axios code:
Thanks in advance!