I'm trying to send an http POST request using the JavaScript Fetch API. What I've got so far looks like this (in TypeScript notation):
const fetchHeaders = new Headers();
fetchHeaders.append("Content-Type", "multipart/form-data; boundary=???");
const fetchOptions: RequestInit = {
method: "Post",
body: this.file,
headers: fetchHeaders
}
await fetch("uri", fetchOptions);
Assuming that this.file
is either a .xls
or .xlsx
Excel file uploaded using a <input type="file">
, how do I find out the boundary to change boundary=???
. When doing this in POSTMAN, the boundary is automatically set and changes for every request.
Edit:
The duplicate question is nowhere close to the same as this one. I tried to cannibalize the accepted answer to suite my needs, but that creates a different Request/Response and therefore the boundary from that method is different than the one that the fetch() actually sends.