Skip to content

Commit

Permalink
properly format query params for get requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mprew97 committed Jul 11, 2024
1 parent 5572d30 commit d33a66f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 1 addition & 11 deletions src/embedded/embeddedManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,11 @@ export class IterableEmbeddedManager {
placementIds: number[]
) {
try {
const params: any = {};
if (placementIds.length > 0) {
params.placementIds = placementIds[0];
if (placementIds.length > 1) {
params.placementIds += placementIds
.slice(1)
.map((id) => `&placementIds=${id}`)
.join('');
}
}
const iterableResult: any = await baseIterableRequest<IterableResponse>({
method: 'GET',
url: ENDPOINTS.get_embedded_messages.route,
params: {
...params,
placementIds,
platform: WEB_PLATFORM,
sdkVersion: SDK_VERSION,
packageName: packageName
Expand Down
4 changes: 4 additions & 0 deletions src/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Axios, { AxiosRequestConfig } from 'axios';
import qs from 'qs';
import { BASE_URL, STATIC_HEADERS, EU_ITERABLE_API } from './constants';
import { IterablePromise, IterableResponse } from './types';
import { AnySchema, ValidationError } from 'yup';
Expand Down Expand Up @@ -46,6 +47,9 @@ export const baseIterableRequest = <T = any>(
headers: {
...payload.headers,
...STATIC_HEADERS
},
paramsSerializer: (params) => {
return qs.stringify(params, { arrayFormat: 'repeat' });
}
});
} catch (error) {
Expand Down

0 comments on commit d33a66f

Please sign in to comment.