Closed joh-klein closed 6 years ago
Hey @joh-klein, thanks for pointing this out! TBH, I'm not sure - that comment was before my time. I have been using it the way you have been here in this example, and I don't expect this change anytime soon.
@yunong maybe you may know?
I also want to know how to use query strings? There's nothing regarding it in docs.
Hi @tanveerrafiqueIVL, you should continue to use options.query
until further notice. We definitely need to get this in the docs, thanks for pointing this out. 👍
So will it work with JSON Client too? Because it wasn't working for me.
For the JSONClient I am using "querystring".
So something like this:
var qs = require('querystring');
var params = {
foo: 'bar',
abc: ['xyz', '123']
};
var options = {
path: '/foo/bar?' + qs.stringify(params)
};
client.get(options, function(err, req, res) { .. });
Apologies @tanveerrafiqueIVL, it looks like I remembered incorrectly. :( I poked through the client code again, it looks like options are getting passed through to underlying http.request method.
@joh-klein's approach is correct for now - you'll have to put it together yourself for the time being, though it appear we could make this easier by adding first class support for it.
Alright. Thank you. :)
looking through the code, I found this: https://github.com/restify/clients/blob/master/lib/HttpClient.js#L722
Evidently doing this is deprecated:
What is the accepted way then?