Support "req.formData()"
See original GitHub issuePrerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn’t contain the answer to my issue
Environment check
- I’m using the latest
msw
version - I’m using Node.js version 14 or higher
Node.js version
16.13.0
Reproduction repository
https://github.com/ddolcimascolo/msw-issue-1327
Reproduction steps
Axios to send a POST request with a FormData body. Try to use req.body in the handler
Current behavior
TypeError: The "input" argument must be an instance of ArrayBuffer or ArrayBufferView. Received an instance of FormData
at new NodeError (node:internal/errors:371:5)
at TextDecoder.decode (node:internal/encoding:413:15)
at decodeBuffer (/data/dev/msw-issue-formdata/node_modules/@mswjs/interceptors/src/utils/bufferUtils.ts:11:18)
at RestRequest.get body [as body] (/data/dev/msw-issue-formdata/node_modules/msw/src/utils/request/MockedRequest.ts:117:18)
Expected behavior
Maybe req.formData()
as per https://developer.mozilla.org/en-US/docs/Web/API/Request/formData would be the way to go?
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:20 (5 by maintainers)
Top Results From Across the Web
Request.formData() - Web APIs - MDN Web Docs
The formData() method of the Request interface reads the request body and returns it as a promise that resolves with a FormData object....
Read more >form-data - npm
A library to create readable "multipart/form-data" streams. Can be used to submit forms and file uploads to other web applications.
Read more >FormData - The Modern JavaScript Tutorial
This chapter is about sending HTML forms: with or without files, with additional fields and so on. FormData objects can help with that....
Read more >node.js, express, how to get data from body form-data in post ...
There is a screenshot in the question, where it can be seen that @alfian5229 sends a form-data request, not json. So express.json() is...
Read more >Form Data - FastAPI
from fastapi import FastAPI, Form app = FastAPI() @app.post("/login/") async def ... flow") it is required to send a username and password as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have been stuck at 0.43.1 because of this isse
req.body was broken after that version (even though it incorrectly says it was depreciated)
@ddolcimascolo, no news so far. Anybody is welcome to take the reproduction repo above and step through this
body
function to find out what happens now withFormData
bodies. Debugging this is about 80% of solving it.