mswjs / http-middleware

Spawn an HTTP server from your request handlers or apply them to an existing server using a middleware.

Home Page:https://npm.im/@mswjs/http-middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incoming request body has been parsed as [object Object]

MysticEyeBlink opened this issue · comments

Making POST request with JSON body, to mocked endpoint, produces body value as [object Object].
The cause of this lays on using express.json() and then non-stringified JSON is changed to ArrayBuffer in createMiddleware.

Parsing text to JSON:

app.use(express.json())

Encoding non-stringified JSON:

body: encodeBuffer(req.body),

Released: v0.5.1 🎉

This has been released in v0.5.1!

Make sure to always update to the latest version (npm i @mswjs/http-middleware@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.