Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

axios how to set header after post

axios returns data in the data object, go with:
const loginHandler = (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)
    }
  }
Source by masteringjs.io #
 
PREVIOUS NEXT
Tagged: #axios #set #header #post
ADD COMMENT
Topic
Name
1+3 =