We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm using NodeJS with Superagent to connect to an API. The URL should look like this:
https://example.com/api/schedule/default/events?query={"jobSourceIds":["614999492641e60d523e1f51"],"status":["ready","notstarted"]}
I've tested this URL in Postman and it works fine.
But Superagent transforms this to:
https://example.com/api/schedule/default/events?query=%7B%22jobSourceIds%22:[%22614999492641e60d523e1f51%22],%22status%22:[%22ready%22,%22notstarted%22]%7D
The query-params are encoded which I don't want since my API can't process it. The API ignores the params this way.
The queryParams are provided as a string in the right form.
I've tried to set the Content-type and request.type to JSON, but no luck.
Any suggestions on how to get this right?
var request = superagent[method.toLowerCase()](baseUrl + path); request.set("Accept", "application/json"); request.set("Cache-Control", "no-cache"); // request.set('Content-Type', 'application/json') request.set('Content-Type', 'application/x-www-form-urlencoded') var headers = createHeaders(method, path); Object.keys(headers).forEach(function (k) { request.set(k, headers[k]); }); request.proxyWrapper = function (proxy) { if (proxy == undefined) return this; return this.proxy(proxy); }; console.log(queryParams) // query={"jobSourceIds":["614999492641e60d523e1f51"],"status":["ready","notstarted"]} console.log(typeof queryParams) // string return request.send(payload).query(queryParams).proxyWrapper(proxy).end(responseHandler);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm using NodeJS with Superagent to connect to an API.
The URL should look like this:
I've tested this URL in Postman and it works fine.
But Superagent transforms this to:
The query-params are encoded which I don't want since my API can't process it.
The API ignores the params this way.
The queryParams are provided as a string in the right form.
I've tried to set the Content-type and request.type to JSON, but no luck.
Any suggestions on how to get this right?
The text was updated successfully, but these errors were encountered: