Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Create Entries

Server error 500 can't post article to database

I have set everything up, but I can't post into the database. The website returns a json with an error message:

name: "SequelizeDatabaseError",
parent: {
errno: 1,
sql: "INSERT INTO `Articles` (`id`,`title`,`author`,`body`,`createdAt`,`updatedAt`) VALUES (NULL,$1,$2,$3,$4,$5);"
original: {
errno: 1,
sql: "INSERT INTO `Articles` (`id`,`title`,`author`,`body`,`createdAt`,`updatedAt`) VALUES (NULL,$1,$2,$3,$4,$5);"
sql: "INSERT INTO `Articles` (`id`,`title`,`author`,`body`,`createdAt`,`updatedAt`) VALUES (NULL,$1,$2,$3,$4,$5);"

The console returns a 500 server error; I have no clue what could be wrong.

nodemon] restarting due to changes...
[nodemon] starting `node ./bin/www`
Executing (default): INSERT INTO `Articles` (`id`,`title`,`author`,`body`,`createdAt`,`updatedAt`) VALUES (NULL,$1,$2,$3,$4,$5);
POST /articles 500 34.016 ms - 469
Seokhyun Wie
.a{fill-rule:evenodd;}techdegree seal-36
Seokhyun Wie
Full Stack JavaScript Techdegree Graduate 21,606 Points

I have the same problem, but only to say the fastest way to get out of this issue is that you download the project file and start everything from Create Entities folder. I've been holding this 500 issue for hours and I found it is not worthwhile at all. I don't like this written part either, but truly guys, no time to stay here and struggle. Wish all of you the best!

1 Answer

I missed this part in the www file:

 * Listen on provided port, on all network interfaces.

sequelize.sync().then(() => {
server.on('error', onError);
server.on('listening', onListening);

Man, these new courses with all the text are not cool. I am just copy pasting stuff instead of following along and I don't feel like I am learning anything