Skip to content
Advertisement

The problem of sending and processing a request to the database

I send requests using postman. And when I send request “POST” for create product (or another requests: GET, PUT , etc), I have problem:

JavaScript

I can’t figure out how I can send a query to my database to get this right.

I use express, sequelize and sequelize-cli, mysql2. And also i have migrations file.

My server.js

JavaScript

productRouter.js

JavaScript

productController.js

JavaScript

productModels.js

JavaScript

product.js

JavaScript

index.js

JavaScript

Advertisement

Answer

Change in productModels.js the function createProduct to:

JavaScript

And do the same to other functions.

Here your model name in products.js:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement