Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use req.body via get request in nodejs

I have a form which uses a GET method. i also have an input with the name 'a'. when i handle the request on the server side (nodejs) i want to be able to use req.body.a (in order to search 'a' in the db). the problem is that the 'req.body' only seems to work with a POST method.

How can i solve this?

like image 277
itay312 Avatar asked Sep 21 '25 13:09

itay312


1 Answers

If you are using GET method then the data is sent as query parameters

req.query

By the way there will be no body for GET method. If you want to send data through body use POST or PUT method.

like image 58
Vishnu Avatar answered Sep 23 '25 04:09

Vishnu