restify/clients

query string in client is missing when there is query string in request

songpr opened this issue · 1 comments

Code below is work!

const rest_clients = require('restify-clients');

let client= rest_clients.createJsonClient({
            url: 'https://graph.facebook.com',
            version: "3.2",
            query: {
                access_token: "xxx"
            }
        });

client.get("/xxxxxxyyyy", function (err, req, res, obj) {
                if (err) {
                    console.log(err);
                    reject(err);
                }
                 console.log(obj);
            });

but if I have more query in a request then.

let options = {path:"/xxxxxxyyyy", query:{fields:"name,gender}};
client.get(options , function (err, req, res, obj) {
                if (err) {
                    console.log(err);
                    reject(err);
                }
                 console.log(obj);
            });

this will not work since access_token query is gone.

What if you’d copy the global query?

const query = Object.assign({ fields: "name,gender" }, client.query)
const options = { path: "/xxxxxxyyyy", query: query }