【发布时间】:2023-01-08 16:06:45
【问题描述】:
//server.js
app.post('/trip', function(req,res){
var params = "something";
getResult(params).then((db)=>{
// I want to access variable named "db" in App.js(React), but I don't know how to do.
res.send(db);
res.end();
});
});
我想在 App.js(React) 中访问名为“db”的变量,但我不知道该怎么做。如果我像这样使用 axios
//App.js
axios.get('http://localhost:3000/trip').then((response)=>{
console.log(response.data);
})
但是打印“GET http://localhost:3000/trip 404 (Not Found)”。我怎么解决这个问题?
【问题讨论】:
标签: javascript node.js reactjs express