requestBody is string `"[object Object]"`
See original GitHub issueGiven the following fetch:
const formData = new FormData();
formData.append('test', 'true');
fetch('http://localhost/api/test', {method: 'POST', body: formData});
When I mock it with nock:
nock('http://localhost')
.post('/api/test')
.reply(function(uri, requestBody) {
console.log(typeof requestBody, requestBody); // string [object Object]
});
the requestBody
is "[object Object]"
. Is that normal? How can I inspect FormData
posted with nock?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Why does the String coming in POST request body ...
Cause. You are making double serialization. call = ApiClient.getInstance().getMyApi().callLogin(gson.toJson(userData));.
Read more >Spring's RequestBody and ResponseBody Annotations
The @ResponseBody annotation tells a controller that the object returned is automatically serialized into JSON and passed back into the ...
Read more >Get HTTP POST Body in Spring Boot with @RequestBody
The @RequestBody annotation allows us to retrieve the request's body. We can then return it as a String or deserialize it into a...
Read more >Describing Request Body
schema that describes the body data type and structure. The data type is usually an object, but can also be a primitive (such...
Read more >The @RequestBody Annotation
The @RequestBody annotation tells Spring to deserialize an incoming request body into an object passed as a parameter to the handler method.
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 Free
Top 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
Gotcha, ended up doing the same thing 😃 Thanks @evandavis !
@sirdavidwong not exactly; we ended up writing a custom stringifier based on the npm version of
form-data
for our tests. Not ideal. (I believe the issue is in how FormData converts to string outside the browser.)