Skip to content

Commit

Permalink
Fix ingesttopics payload (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
MO-Thibault authored Feb 16, 2024
1 parent 3fdef56 commit 4467645
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/addons/topics-api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("OptableSDK - ingestTopics", () => {

// Expectations
expect(SDK.getTopics).toHaveBeenCalledTimes(1);
const expectedTopicsApi = topics.map(topic => JSON.stringify(topic)).join('|');
const expectedTopicsApi = topics.map(topic => `taxonomy version ${topic.taxonomyVersion}, topic ${topic.topic}`).join('|');
expect(SDK.profile).toHaveBeenCalledWith({ topics_api: expectedTopicsApi });
});

Expand Down
16 changes: 8 additions & 8 deletions lib/addons/topics-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OptableSDK.prototype.getTopics = async function(): Promise<BrowsingTopic[]> {
}
const getTopicsURL = new URL(siteConfig.getTopicsURL);
const topicsFrame = document.createElement("iframe");
topicsFrame.src = getTopicsURL.toString()
topicsFrame.src = getTopicsURL.toString();
topicsFrame.allow = "browsing-topics " + getTopicsURL.origin;
topicsFrame.style.display = "none";

Expand All @@ -35,13 +35,13 @@ OptableSDK.prototype.getTopics = async function(): Promise<BrowsingTopic[]> {
}

if (event.data.error) {
reject(new Error(event.data.error.toString()))
reject(new Error(event.data.error.toString()));
return
}

resolve(event.data.result)
})
})
resolve(event.data.result);
});
});

document.body.appendChild(topicsFrame);
return topicsPromise;
Expand All @@ -54,8 +54,8 @@ OptableSDK.prototype.ingestTopics = function() {
this.getTopics()
.then((topics) => {
if (!topics.length) { return }
const topics_api = topics.map(topic => JSON.stringify(topic)).join('|')
this.profile({ topics_api })
const topics_api = topics.map(topic => `taxonomy version ${topic.taxonomyVersion}, topic ${topic.topic}`).join('|');
this.profile({ topics_api });
})
.catch(() => { })
.catch(() => { });
}

0 comments on commit 4467645

Please sign in to comment.