Request: how to pass params in request.get?

Created on 9 Aug 2017  路  3Comments  路  Source: request/request

how to pass params in request.get?
why can't pass params like jquery?
$.get("xxx.com", { name:"Donald", remarks:"Ducktown" });

Most helpful comment

@chenby
You can pass them as the query string (qs) parameters:

request.get('xxx.com', {qs: {
    name: 'Donald',
    remarks: 'Ducktown'
}}, (err, res, body) => {
   ...
})

All 3 comments

You append them to the url:

xxx.com?name=Donald&remarks=Ducktown

But, if i have a params like object, and i must parse it as string.

@chenby
You can pass them as the query string (qs) parameters:

request.get('xxx.com', {qs: {
    name: 'Donald',
    remarks: 'Ducktown'
}}, (err, res, body) => {
   ...
})
Was this page helpful?
0 / 5 - 0 ratings