Answers for "axios response header get"

15

pass header in axios

const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'JWT fefege...'
}

axios.post(Helper.getUserAPI(), data, {
    headers: headers
  })
  .then((response) => {
    dispatch({
      type: FOUND_USER,
      data: response.data[0]
    })
  })
  .catch((error) => {
    dispatch({
      type: ERROR_FINDING_USER
    })
  })
Posted by: Guest on August-17-2020
0

send xmlhttprequest with axios

var instance = axios.create({
  baseURL: 'https://some-domain.com/api/',
  headers: {"X-Requested-With": "XMLHttpRequest"}
});
Posted by: Guest on December-01-2020

Browse Popular Code Answers by Language