rsnext/test/integration/api-support/pages/api/no-parsing.js

22 lines
383 B
JavaScript
Raw Normal View History

export const config = {
api: {
bodyParser: false,
},
}
export default (req, res) => {
2020-05-18 21:24:37 +02:00
return new Promise((resolve) => {
if (!req.body) {
let buffer = ''
2020-05-18 21:24:37 +02:00
req.on('data', (chunk) => {
buffer += chunk
})
req.on('end', () => {
res.status(200).json(JSON.parse(Buffer.from(buffer).toString()))
resolve()
})
}
})
}