Skip to content

Commit

Permalink
added guard for section query param
Browse files Browse the repository at this point in the history
  • Loading branch information
Hernanfaifman authored and Hernanfaifman committed Apr 5, 2024
1 parent 81fc913 commit deeaaf3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions spec/src/modules/recommendations.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ describe('ConstructorIO - Recommendations', () => {
});
});

it('Should add the section query param when section parameter is provided', (done) => {
it.only('Should add the section query param when section parameter is provided', (done) => {
const { recommendations } = new ConstructorIO({
...validOptions,
fetch: fetchSpy,
Expand All @@ -691,7 +691,7 @@ describe('ConstructorIO - Recommendations', () => {
});
});

it('Should not add the section query param if it is not provided', (done) => {
it.only('Should not add the section query param if it is not provided', (done) => {
const { recommendations } = new ConstructorIO({
...validOptions,
fetch: fetchSpy,
Expand Down
3 changes: 2 additions & 1 deletion src/modules/recommendations.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ class Recommendations {
const controller = new AbortController();
const { signal } = controller;
const headers = {};
const rawQueryParams = qs.stringify(parameters);
const { section } = parameters;
const rawQueryParams = section ? qs.stringify({ section }) : '';
const queryParams = rawQueryParams ? `&${rawQueryParams}` : '';
const requestUrl = `${serviceUrl}/v1/recommendation_pods?key=${apiKey}${queryParams}`.trim();

Expand Down

0 comments on commit deeaaf3

Please sign in to comment.