[英]Vuejs post does not find NodeJs Express server/action
I'm trying to send data using vue.js to my node.js server, but the browser console keeps showing me a 404: POST http://127.0.0.1:63342/myaction 404 (Not Found)
我正在尝试使用vue.js将数据发送到我的node.js服务器,但是浏览器控制台不断向我显示404:
POST http://127.0.0.1:63342/myaction 404 (Not Found)
vue.js: vue.js:
this.$http.post('http://127.0.0.1:63342/myaction', this.formData).then(response => {
console.log(response.body);
}
node.js: Node.js的:
var express = require('express');
var bodyParser = require('body-parser');
var exp = express();
exp.use(bodyParser.urlencoded({extended: true}));
exp.post('/myaction', function (req, res) {
res.send('saved: "' + req.body.name + '".');
});
exp.listen(63342, function () {
console.log('Server running at', this.address());
});
When I start my server, it says it's running at { address: '::', family: 'IPv6', port: 63342 }
当我启动服务器时,它说它正在
{ address: '::', family: 'IPv6', port: 63342 }
The POST
worked without vue.js, by simply submitting a HTML form
, but now AJAX doesn't wordk. POST
无需vue.js,只需提交HTML form
,但现在AJAX不再使用。 I tried multiple ports and folders, but can't figure out the mistake. 我尝试了多个端口和文件夹,但无法找出错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.