axios.post('https://example.com/postSomething',{// this is the bodyemail: varEmail,password: varPassword
},{headers:{Authorization:'Bearer '+ varToken
}})
const axios =require('axios');// httpbin.org gives you the headers in the response// body `res.data`.// See: https://httpbin.org/#/HTTP_Methods/get_getconst res =await axios.get('https://httpbin.org/get',{headers:{'Test-Header':'test-value'}});
res.data.headers['Test-Header'];// "test-value"
axios returns data in the data object, go with:constloginHandler=(e)=>{
e.preventDefault();try{
axios.post('http://localhost:5000/api/auth/login',{
email,
password
}).then(res=>localStorage.setItem("refreshToken", res.data.refreshToken))}catch(err){console.log(err)}}