To make Node.js http ‘get’ request with query string parameters, we set the qs
property.
For instance, we write
const request = require("request");
const propertiesObject = { field1: "test1", field2: "test2" };
request({ url, qs: propertiesObject }, (err, response, body) => {
if (err) {
console.log(err);
return;
}
console.log(response.statusCode);
});
to call request
to make a request to url
and we set the quert string by setting qs
to an object with the keys and values for the query string.
Then we get the response from the response
parameter and the response body from the body
parameter.