1
axios.post('http://drupal-site.local/user/login?_format=json',{
    "name": username,
    "pass": password
  }).then(resp..................})

Here I'm calling Drupal login API in react(http://localhost:3000). Cookies are not set in headers. If I'm calling in postman same API then cookies are setting in headers. I tried with {withCredentials: true} and include: credentials but no use.

 axios.post('http://drupal-site.local/user/login?_format=json', {
  "name": username,
  "pass": password
}, {
  withCredentials: true, // or 
  credentials: include
})
.then(() => {})
ztadic91
  • 2,774
  • 1
  • 15
  • 21
acrostic
  • 21
  • 2
  • Axios makes an asynchronous request, while postman is a browser (chrome extension) – Dhiraj Dec 03 '18 at 12:50
  • 1
    Possible duplicate of [Make Axios send cookies in its requests automatically](https://stackoverflow.com/questions/43002444/make-axios-send-cookies-in-its-requests-automatically) – Agney Dec 03 '18 at 12:50
  • @BoyWithSilverWings I already tried with {withcredentials:true} and credentials: include also but no use – acrostic Dec 03 '18 at 13:16

0 Answers0