Axios doesn't send cookies with POST and data · Issue #876 ... | axios credentials include
Justincaseanyoneelsestumblesacrossthisthread"googling"forasolution.IfyouarewantingtopassastructasasetofformfieldslikeyoumightdoinjQueryyouwouldlikelybetryingsomethinglikethiswhenusingaxios(thiswillnotworkandexhibitsthebehaviortitlingthisissue):config={url:http://somedomain,method:post,withCredentials:true,data:{myfield:"myvalue"}};axios.request(config);formData=newFormData();formData.append(myfield,myvalue);config={url:http://somedomain,method:post,withCredentials:true,data:formData};axios.r...
Just in case anyone else stumbles across this thread "googling" for a solution.
If you are wanting to pass a struct as a set of form fields like you might do in jQuery you would likely be trying something like this when using axios (this will not work and exhibits the behavior titling this issue):
config = { url:http://somedomain, method:post, withCredentials: true, data:{myfield:"myvalue"} }; axios.request(config); formData = new FormData(); formData.append(myfield,myvalue); config = { url:http://somedomain, method:post, withCredentials: true, data:formData }; axios.request(config);Doing the above allowed me to post my form data cross origin while also ensuring cookies were being passed along for the ride.
Access-Control-Allow-Credentials true Access-Control-Allow-Headers X-PINGOTHER, Content-Type Access-Control-Allow-Methods GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS Access-Control-Al...