我正在开发一个NodeJS API,我有下面的文件夹 struct .我需要从index.js
本身提取API调用的请求体信息,然后将其传递给StripeController.js stripeController.js
.
- Index.js index.js
- 控制器
- StripeController.js stripeController.js
我使用下面的代码段从
index.js
中提取数据,但是它返回undefined
,因为它在请求通过index.js
时无法识别req.body
.app.use((req, res, next) => { if (req.originalUrl.startsWith('/api/stripeWebHook')) { console.log(req.body) next(); } }); const stripeWebHook = require('./webhook/stripeWebHook') app.use('/api/stripeWebHook', stripeWebHook) module.exports = app
我可以使用相同的属性简单地提取身体,当它达到
StripeController.js stripeController.js
时.我怎么才能解决这个问题呢?
- 控制器