opened 11:39AM - 24 Jun 20 UTC
closed 07:40AM - 29 Jun 20 UTC
<!--
Hello 👋 Thank you for submitting an issue.
Before you start, please mak…e sure your issue is understandable and reproducible.
To make your issue readable make sure you use valid Markdown syntax.
https://guides.github.com/features/mastering-markdown/
Please ensure you have also read and understand the contributing guide.
https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md#reporting-an-issue
-->
**Describe the bug**
I am trying to obtain the raw request body to I can verify it using Stripe's library. This question was previously asked #4720, but the solution the user posted no longer seems to work.
**Steps to reproduce the behavior**
1. Create a `config/env/**/request.json` with the following content:
```json
{
"parser": {
"enabled": true,
"multipart": true,
"includeUnparsed": true
}
}
```
2. Import the `unparsed` symbol helper from `koa-body`
```js
const unparsed = require('koa-body/unparsed.js');
```
3. Attempt to access the unparsed body.
```js
async index(ctx) {
const unparsedBody = ctx.request.body[unparsed];
console.log(unparsedBody) // undefined
}
```
**Expected behavior**
I would have received the unparsed body.
**Screenshots**
N/A
**Code snippets**
config/env/development/request.json
```json
{
"parser": {
"enabled": true,
"multipart": true,
"includeUnparsed": true
}
}
```
api/test/controllers/test.js
```js
"use strict";
const unparsed = require("koa-body/unparsed.js");
module.exports = {
async test(ctx) {
console.log("\n==== Environment =======================");
console.log(`NODE_ENV=${process.env.NODE_ENV}`);
console.log("\n==== Requests Config ===================");
console.log(strapi.config.request);
console.log("\n==== Unparsed Symbol ===================");
console.log(unparsed);
console.log("\n==== Unparsed Body =====================");
console.log(ctx.request.body[unparsed]);
console.log("");
return {};
},
};
```
Output:
```
==== Environment =======================
NODE_ENV=development
==== Requests Config ===================
{ parser: { enabled: true, multipart: true, includeUnparsed: true } }
==== Unparsed Symbol ===================
Symbol(unparsedBody)
==== Unparsed Body =====================
undefined
```
**System**
- Node.js version: 12.16.1
- NPM version: 6.13.4 (Yarn 1.22.4)
- Strapi version: 3.0.1
- Database: PostgreSQL
- Operating system: macOS 10.15.5