【发布时间】:2021-01-04 14:04:32
【问题描述】:
我正在使用 NodeJS 和 Express,我想从请求中获取用户名和密码参数。我已经搜索了一段时间,但我找不到我的答案。
我想接受来自 cURL 命令的 user 参数:
curl --request --POST -u USERNAME:PASSWORD -H "Content-Type:application/json" -d "{\"key":\"value\"}" --url https://api.example.com/my_endpoint
在我的应用程序中:
app.post('/my_endpoint', async (req, res, next) => {
const kwargs =. req.body;
const userName = req['?'];
const password = req['?'];
});
【问题讨论】: