Skip to content

Commit

Permalink
fix: axios expects paramsSerializer (twilio#82)
Browse files Browse the repository at this point in the history
* fix: axios expects paramsSerializer

* add test
  • Loading branch information
eshanholtz committed Mar 30, 2020
1 parent 189e5d9 commit 8c55d29
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/cli-http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CliRequestClient {

if (opts.params) {
options.params = opts.params;
options.paramSerializer = params => {
options.paramsSerializer = params => {
return qs.stringify(params, { arrayFormat: 'repeat' });
};
}
Expand Down
16 changes: 16 additions & 0 deletions test/services/cli-http-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,21 @@ describe('services', () => {
const request = client.request({ method: 'GET', uri: 'https://foo.com/bar' });
await expect(request).to.be.rejectedWith(TwilioCliError);
});

test
.nock('https://foo.com', api => {
api.get('/bar?foo=bar&foo=baz').reply(200);
})
.it('correctly serializes array parameters', async () => {
const client = new CliRequestClient('bleh', logger);
const response = await client.request({
method: 'GET',
uri: 'https://foo.com/bar',
params: {
foo: ['bar', 'baz']
}
});
expect(response.statusCode).to.equal(200);
});
});
});

0 comments on commit 8c55d29

Please sign in to comment.