I am using node js and dynamoose to interact with dynamodb. When I try to create a new object Dynamo returns this error. The problem is not with what is coming in on the request, but with dynamoose. The function that is being hit starts at line 5. The error is caused by invoking the function create() on line 6. I have checked the model prototype and it does contain the create function.
'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
via CLR45
No comments:
Post a Comment