【发布时间】:2017-12-15 05:29:51
【问题描述】:
我想发布对象并在节点服务器上读取它,但我有一个错误。
控制器:
$scope.update = function(contact) {
console.log(contact);
$http.post('/contactlist/' + contact).then(function(response) {
console.log(response);
});
};
服务器节点:
app.post('/contactlist/:contact', function (req, res, next) {
console.log(req.body);
res.json();
});
服务器节点头:
var express = require('express');
var app = express();
var mysql = require('mysql');
var bodyParser = require('body-parser');
var connection = *****************
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({extended:false}));
app.use(express.static(__dirname + "/public"));
错误网络POST截图: enter image description here
console.log(req.body) 的服务器错误;
[object Object]
SyntaxError: Unexpected token o in JSON at position 1
【问题讨论】: