GET requests with Promise interface do not send query parameters
I'm trying to use the Promise based interface to make a GET request that includes query string parameters. I've created a URL using https://postb.in to observe the request as its received.
needle('get', 'http://postb.in/xjXUccQg', { token: 'hello' })
.then(console.log)
.catch(console.error);
The above code never sends the token parameter. When using the callback interface, I am able to get this to work.
needle.request('get', 'http://postb.in/xjXUccQg', { token: 'hello' }, (error, response) => {
if (error) { return console.error(error); }
console.log(response);
});
You're right. The Promise-based interface currently does not expect any params for GET requests. This should probably change, though, to reflect the same behaviour as in needle.request. Thanks for the heads up!
Any workaround ?
I am trying below code that always throwing error.
needle('get','https://url.com/v1/get/match',params,options, function(err, resp ) {
@Sreekusak if you look at the code https://github.com/tomas/needle/blob/master/lib/needle.js#L347 you can do the same thing. querystring can be imported like import * as querystring from 'needle/lib/querystring'; Would be nice to have it still but that should work for you.
Happy to accept pull requests if anybody's up to the challenge. :)