ShubhamOriginal post
Rank 3: Container
useEffect(() => {
const fetchData = async () => {
try {
const userToken =JSON.parse( localStorage.getItem("cookieFallback"));
const token=userToken[a_session_${process.env.REACT_APP_PROJECT_ID}]
console.log(token)
const config = {
headers: {
Authorization: Bearer ${token}
}
};
const response = await axios.post('http://localhost:3001/dashborddata/',null,config);
console.log(response.data);
} catch (error) {
console.log(error.message);
}
};
fetchData();
}, []);
Summary
Developers are encountering an 'invalid jwt' error in the backend even after providing the correct user token. The issue seems to be related to JWT authentication. Make sure the token is correctly parsed and passed in the Authorization header. Double-check the token generation and verify that the token provided is valid and not expired.