Skip to content

Commit 8c55d29

Browse files
authored
fix: axios expects paramsSerializer (twilio#82)
* fix: axios expects paramsSerializer * add test
1 parent 189e5d9 commit 8c55d29

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/services/cli-http-client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class CliRequestClient {
7878

7979
if (opts.params) {
8080
options.params = opts.params;
81-
options.paramSerializer = params => {
81+
options.paramsSerializer = params => {
8282
return qs.stringify(params, { arrayFormat: 'repeat' });
8383
};
8484
}

test/services/cli-http-client.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,21 @@ describe('services', () => {
4848
const request = client.request({ method: 'GET', uri: 'https://foo.com/bar' });
4949
await expect(request).to.be.rejectedWith(TwilioCliError);
5050
});
51+
52+
test
53+
.nock('https://foo.com', api => {
54+
api.get('/bar?foo=bar&foo=baz').reply(200);
55+
})
56+
.it('correctly serializes array parameters', async () => {
57+
const client = new CliRequestClient('bleh', logger);
58+
const response = await client.request({
59+
method: 'GET',
60+
uri: 'https://foo.com/bar',
61+
params: {
62+
foo: ['bar', 'baz']
63+
}
64+
});
65+
expect(response.statusCode).to.equal(200);
66+
});
5167
});
5268
});

0 commit comments

Comments
 (0)