balderdashy / balderdashy/sails

How to prevent insert of data that is passed using query string in sails.js for post request?

Open
#6,918 6 comments 0 reactions 0 assignees View on GitHub
helpful info or workaround mysql orm question
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I have created new table in mysql also created model and controller in sails.js. Now I am trying to insert data using sails. As we know when we create new modal in sails it will create new post, get and other api for us by default.

Now I am trying to insert data using post api using query string and request.body and both are working But **I need to insert data into db that is passed using request.body instead of request.querystring data in post request. How can I do it???**

1. Post data using query string in post request => working fine

![image](https://user-images.githubusercontent.com/16740406/71478646-c227c800-2816-11ea-961f-67eb26c2b7ce.png)

2. Post data using request.body in post request => **working fine (I want to insert data using this way only)**

![image](https://user-images.githubusercontent.com/16740406/71478665-d075e400-2816-11ea-9d35-678b33ed4703.png)

Contributor guide

Open the contributing guide

Research direction

Start with the Sails model and controller that provide the generated POST endpoint, then review how request.body and the query string are handled. Reproduce both requests against the MySQL-backed model and confirm that values from request.body are persisted without query-string data being inserted or taking precedence.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mysql
Domain
api, backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.