我的项目捆绑在webpack(localhost:9000)上。我确实将请求发布到其他本地服务器(localhost:3000),现在我需要在localhost:9000 / etc上获取此数据。我试图在localhost:3000上获取请求,但这是不正确的。请向我解释,我该怎么办?
我的请求
function getReq() {
fetch('http://localhost:3000/test')
.then(response => {
response.json();
})
.then(data => {
// Work with JSON data here
console.log(data.body);
}).catch(err => {
// Do something for an error here
console.log("Error Reading data " + err);
})
}
getReq()
我的服务器(我需要发送请求正文)
app.post('/post',(req,res) => {
console.log(req.body)
app.get('/test',(request,response)=>{
response.send(req.body)
})
res.send('ok')
})