预期数组但收到
Expected Array but received
我是 Angular 的新手,我正在尝试为事件实施日历。
我正在使用 Angular UI 日历。当我 post 数据时,它得到 posted 但它给出了一个错误。
POST 方法
$http({
method : 'POST',
url : '/api/appointment',
data : $scope.appointment
}).success(function(data) {
console.log(data);
}).error(function(err) {
console.log(err);
});
预期数组但收到:
{ "__v": 0,
"visitType": "Referral",
"timeDuration": "900000",
"patientId": "BMSHT002",
"doctorId": "BMSHTDOC60",
"_id": "5833da8d9889edd037a54c30",
"eventSources": [{
"title": "Patient Name : Vignesh\t Age :10\t Gender : male\t Email Id : bvikcy.2205@gmail.com\n Appointment Type : Referral\n Doctor Name : Demo 1",
"start": "2016-11-21T04:30:00.000Z",
"end": "2016-11-21T04:45:00.000Z",
"_id": "5833da8d9889edd037a54c31"
}]
}
我知道这是一个 JSON 数据,但我不太确定如何解决这个问题。有人可以帮我解决这个问题吗?
这是我在 post 处理数据时使用的架构
var appointmentSchema = mongoose.Schema({
patientId : String,
doctorId : String,
visitType : String,
timeDuration : String,
eventSources: [{
title : String,
start : Date,
end : Date
}]
});
节点 JS 代码
router.route('/appointment')
.post(function(req, res) {
var appointmentData = req.body;
var appointments = new Appointment(appointmentData);
console.log(appointments);
appointments.save(function(err, appointment) {
if (err)
throw err;
res.send(appointment);
})
})
提前致谢
而不是 'res.send',尝试 'res.json' 如下
router.route('/appointment')
.post(function(req, res) {
var appointmentData = req.body;
var appointments = new Appointment(appointmentData);
console.log(appointments);
appointments.save(function(err, appointment) {
if (err)
throw err;
res.json(appointment);
})
})
我是 Angular 的新手,我正在尝试为事件实施日历。 我正在使用 Angular UI 日历。当我 post 数据时,它得到 posted 但它给出了一个错误。
POST 方法
$http({
method : 'POST',
url : '/api/appointment',
data : $scope.appointment
}).success(function(data) {
console.log(data);
}).error(function(err) {
console.log(err);
});
预期数组但收到:
{ "__v": 0,
"visitType": "Referral",
"timeDuration": "900000",
"patientId": "BMSHT002",
"doctorId": "BMSHTDOC60",
"_id": "5833da8d9889edd037a54c30",
"eventSources": [{
"title": "Patient Name : Vignesh\t Age :10\t Gender : male\t Email Id : bvikcy.2205@gmail.com\n Appointment Type : Referral\n Doctor Name : Demo 1",
"start": "2016-11-21T04:30:00.000Z",
"end": "2016-11-21T04:45:00.000Z",
"_id": "5833da8d9889edd037a54c31"
}]
}
我知道这是一个 JSON 数据,但我不太确定如何解决这个问题。有人可以帮我解决这个问题吗?
这是我在 post 处理数据时使用的架构
var appointmentSchema = mongoose.Schema({
patientId : String,
doctorId : String,
visitType : String,
timeDuration : String,
eventSources: [{
title : String,
start : Date,
end : Date
}]
});
节点 JS 代码
router.route('/appointment')
.post(function(req, res) {
var appointmentData = req.body;
var appointments = new Appointment(appointmentData);
console.log(appointments);
appointments.save(function(err, appointment) {
if (err)
throw err;
res.send(appointment);
})
})
提前致谢
而不是 'res.send',尝试 'res.json' 如下
router.route('/appointment')
.post(function(req, res) {
var appointmentData = req.body;
var appointments = new Appointment(appointmentData);
console.log(appointments);
appointments.save(function(err, appointment) {
if (err)
throw err;
res.json(appointment);
})
})