Closed FergusDevelopmentLLC closed 7 years ago
I am trying to get a simple example working. I'm a node, sequelize, epilogue noob.
Here's my server.js...
var Sequelize = require('sequelize'), epilogue = require('epilogue'), http = require('http'), express = require('express'), bodyParser = require('body-parser'); var port = process.env.PORT || 9001; var database = new Sequelize("postgres://geodevdb:XXX@127.0.01:15432/geodevdb"); //Define your models var User = database.define('User', { username: Sequelize.STRING, birthday: Sequelize.DATE }); // var restify = require('restify'); // var app = restify.createServer() // app.use(restify.queryParser()); // app.use(restify.bodyParser()); var app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); //issue not effected by toggling restify/express server = http.createServer(app); // Initialize epilogue epilogue.initialize({ app: app, sequelize: database }); // Create REST resource var userResource = epilogue.resource({ model: User, endpoints: ['/users', '/users/:id'] }); // Create database and listen database .sync({ force: false }) .then(function() { app.listen(port, function() { console.log('listening at %s', port); }); });
Here's my post request and response to create a new user...
Here's my console output:
Why are null values inserted for username/birthday?
needed to use application/json when making the post.
I am trying to get a simple example working. I'm a node, sequelize, epilogue noob.
Here's my server.js...
Here's my post request and response to create a new user...![](http://storage3.static.itmages.com/i/17/0619/h_1497904352_9527452_5ced54b0b0.png)
Here's my console output:![](http://storage4.static.itmages.com/i/17/0619/h_1497904562_1297181_e8cd340ee4.png)
Why are null values inserted for username/birthday?