mahnoorfatima / Assignment-WebScrapper

0 stars 0 forks source link

req.query #1

Open neebz opened 4 years ago

neebz commented 4 years ago

https://github.com/mahnoorfatima/Assignment-WebScrapper/blob/ec53d357002a0798e84cdf7cbdd3d3e37b3b0ff4/controller.js#L11

All parameters passed in URL after ?= are called query parameters. To access query parameters please use the query object. see documentation: https://expressjs.com/en/4x/api.html#req.query

above code should be changed to request.query.address

mahnoorfatima commented 4 years ago

All parameters passed in URL after ?= are called query parameters.Yes To access query parameters please use the query object . Yes There are 2 kind of Use Cases 1 - address param exist in the Url This comes with two further usecase i - address parameter is defined ?address=www.google.com the req.query.address will return the value of address. ii - address parameters is in array ?address=www.google.com&address=www.dawn.com/events the req.query.address is instance of array

2 - address param doesn't exist The req.query.address returns undefined. There for i have use request.url.indexOf("address=") to check the index of address param.