thanks stopping by.
i want send new formdata() body of post request using fetch api
the operation looks this
var formdata = new formdata() formdata.append('myfile', file, 'somefilename.csv') fetch('https://api.myapp.com', { method: 'post', headers: { "content-type": "multipart/form-data" }, body: formdata } ) the problem here boundary,
boundary=----webkitformboundaryyemkndsbkjb7qequ
never makes content-type: header
it should this
content-type:multipart/form-data; boundary=----webkitformboundaryyemkndsbkjb7qequ
when try "same" operation new xmlhttprequest(), so
var request = new xmlhttprequest() request.open("post", "https://api.mything.com") request.withcredentials = true request.send(formdata) the headers correctly set
content-type:multipart/form-data; boundary=----webkitformboundaryyemkndsbkjb7qequ
so question is,
how make
fetchbehavexmlhttprequestin situation?if not possible, why?
thanks everybody! community more or less reason have professional success.
the solution problem explicitly set content-type undefined browser or whatever client you're using can set , add boundary value in there you. disappointing true.
Comments
Post a Comment