How To Get Form Data From Webkitformboundary

Hi, I have an NodeJS App and a client that sends a POST request to my NodeJS server using a FormData object inside the body of the request. The code below is what I can see from the request.body on the server side.

Đang xem: File upload includes webkitformboundary header and footer · issue #168 · github/fetch · github

My question is, how do I retrieve email and name values?

{

“——WebKitFormBoundaryrJKU9kYIUM7J5oS3
Content-Disposition

: form-data;

name”:””email”

test
gmail.com

——WebKitFormBoundaryrJKU9kYIUM7J5oS3
Content-Disposition

: form-data;

name=”password1″

123

——WebKitFormBoundaryrJKU9kYIUM7J5oS3
Content-Disposition

: form-data;

name=”password2″

123

——WebKitFormBoundaryrJKU9kYIUM7J5oS3–

}

*

Have you tried using formidable as a middleware?

https://www.npmjs.com/package/formidable

If this doesn't work, I need to see the entire request packet including headers to help you out. If you can, you should migrate to using AJAX requests to make it easier on yourself in the future.

Xem thêm: Cách Tải Game Audition 4 – Cách Tải Link Và Cài Game Audition Vtc Online

Thanks for the reply. I changed how I was sending the request from the client side. I changed Content-type from application/x-www-form-urlencoded to application/json.

Xem thêm: Tải Game L.A Noire Complete Edition Việt Hóa (Full Dlc) Crack

However, I am unsure if using Content-type application/json to hold user email and password is the correct way to go.

EX:

const handleSubmit = (e) => {e.preventDefault();const formData = new FormData(e.target);const = formData.values();

fetch('/login', {method: 'POST',headers : {'Content-Type' : 'application/json'},body: JSON.stringify({email, password})}).then(result =>{ //result is a ReadableStream objectreturn result.json(); //result.json() parses the data into useable format (json)}).then(data => {if(data.isAuthenticated){handleUserAuthChange(true, ()=>{history.push('/vehicles');});}}).catch(err => console.log(err));}

1
Reply
Share
ReportSave
Continue this thread 

View Entire Discussion (3 Comments)
More posts from the node community
Continue browsing in r/node

*

r/node
Welcome to node
186k
Members

287

Online

Created Dec 16, 2009
Join
helprev-conf.org Apprev-conf.org coinsrev-conf.org premiumrev-conf.org gifts
aboutcareerspressadvertiseblogTermsContent policyPrivacy policyMod policy
Back to Top

Leave a comment

Your email address will not be published. Required fields are marked *