A
A
Alexander Koshelev2018-06-10 15:26:50
Node.js
Alexander Koshelev, 2018-06-10 15:26:50

How to correctly form multipart form-data to send a POST request to node-fetch?

Good afternoon guys, please tell me how to correctly form the request body?
Here is a part of my code, here is a method, the headers are passed by the object and body in which you need to put multipart form data

fetch(server, { method: 'POST', headers: myHeaders, body: body, credentials:'same-origin'})

Here is part of what needs to be passed to the body (just a lot of these lines there, so I post part of it)
0
------WebKitFormBoundaryh7d8anwOMRWaKLOb
Content-Disposition: form-data; name="Filename"

1528584248.huf680792e391ddf39.mail.pchome.com.tw,S=0
------WebKitFormBoundaryh7d8anwOMRWaKLOb
Content-Disposition: form-data; name="Rmfile"


------WebKitFormBoundaryh7d8anwOMRWaKLOb
Content-Disposition: form-data; name="Savefolder"


------WebKitFormBoundaryh7d8anwOMRWaKLOb
Content-Disposition: form-data; name="new_attachment"

a%3A0%3A%7B%7D
------WebKitFormBoundaryh7d8anwOMRWaKLOb
Content-Disposition: form-data; name="Timestamp"

1528584248
------WebKitFormBoundaryh7d8anwOMRWaKLOb
Content-Disposition: form-data; name="backup"

I formed them body = ['0\r\n\------WebKitFormBoundaryh7d8anwOMRWaKLOb\r\n\Content-Disposition: form-data; name="Filename"\r\n\r\n\1528584248.huf680792e391ddf39.mail.pchome.com.tw,S=0------\r\n\WebKitFormBoundaryh7d8anwOMRWaKLOb\r\n\r\n\ AND SO FURTHER ']
But I'm not forming something correctly, because the answer gives me an erroneous answer, but the response status is 200 OK, that is, somehow I'm not passing the body correctly
Please tell me!!!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question