【发布时间】:2023-02-23 23:50:42
【问题描述】:
我正在像这样进行 api 调用
axios.get("http://localhost:4000/loginUser", { 邮箱: enteredEmail, 密码: enteredPass})
现在我想在服务器代码中访问这些提供给 API 调用的电子邮件和密码字段,
app.get("/loginUser", async (req, res) => {
try {
email = // don't know how to access this email field from **req**
} catch (error) {
res.status(400).send("invalid credentials");
}
});
我尝试从 res.body 访问它,但它是空的,因为我将数据作为有效负载传递。并尝试作为参数传递,但电子邮件中的 @ 符号出现问题。
【问题讨论】:
标签: javascript node.js api server