我正在使用节点js和dynamoose与dynamodb进行交互。当我尝试创建一个新对象时,Dynamo会返回此错误。问题不在于请求的内容,而在于动态。正在命中的函数从第5行开始。该错误是由第6行调用函数create()引起的。我检查了模型原型,它确实包含了create函数。
'use strict';
2
3 const Aircraft = require('../../aircraft.dynamo/index');
4
5 function createAircraft(req, res, next) {
6 Aircraft.create(req.body, (aircraft) => {
7 return res.status(201).json(aircraft);
8 });
9 }
10
11 module.exports = createAircraft;
TypeError: Cannot read property 'name' of undefined
<br> at NewModel.Model.put (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/dynamoose/lib/Model.js:202:72)
<br> at Function.Model.create (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/dynamoose/lib/Model.js:247:16)
<br> at Function.NewModel.create (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/dynamoose/lib/Model.js:99:18)
<br> at createAircraft (/Users/chrisrijos/SideProjects/aircraft-api/server/api/Aircraft/aircraft.controller/createAircraft/index.js:6:14)
<br> at Layer.handle [as handle_request] (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/layer.js:95:5)
<br> at next (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/route.js:137:13)
<br> at Route.dispatch (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/route.js:112:3)
<br> at Layer.handle [as handle_request] (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/layer.js:95:5)
<br> at /Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/index.js:281:22
<br> at Function.process_params (/Users/chrisrijos/SideProjects/aircraft-api/node_modules/express/lib/router/inde