javascript - 将 res.send 值从 node.js 后端传递给 react.js
问题描述
我正在尝试使用 res.send 从 nodejs 后端传递一个字符串
app.post("/user", (req,res) => {
console.log(req.body.email);
res.send('haha');
});
我想根据前端检索到的字符串值执行一些操作。
axios({
method: 'post',
url: '/user',
data: { email: this.state.emailFetch }
}).then(response => {
if(response.send == "haha")
{
return <Redirect to="/"/>
}
});
我想我在前端的响应处理上搞砸了。任何人都可以指导我吗?
解决方案
Try response.data
,res.send()
只是发送响应的功能。您还可以控制台记录整个响应以检查响应值的存储位置。
推荐阅读
- android - 如何向 Lottie 动画添加新角色
- go - 我如何对来自 golang 的长度为 32 [] 字节的 nonce 进行编码以访问 rust 的 jormungandr rpc 服务器?
- javascript - ScrollIntoView 哪儿也不去
- mongodb - $match 在查找阶段而不删除 mongoDB 中的本地文档
- ruby-on-rails - 在哪里为 RoR 中的 gem 定义一个类?
- android - 如何在我的 Android 应用程序上从服务器下载新贴纸?
- python - 尝试运行可执行文件时出现 Nuitka 致命 Python 错误
- c++ - 指针向量在 push_back 上抛出错误
- python - 在 nvidia jetson 上运行 deep-daze -“找不到满足要求的版本 torchvision>=0.8.2”
- sql - 如何在sql中获取行索引