Skip to content

Commit 73db122

Browse files
committed
Bug fix: passing other params to 'by id' endpoints.
1 parent dc96de8 commit 73db122

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "podcast-api",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "JavaScript bindings for the Listen Notes Podcast API",
55
"main": "src/PodcastApiClient.js",
66
"scripts": {

src/PodcastApiClient.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ const Client = (config = {}) => {
3737
this.fetchPodcastById = (params) => {
3838
const { id, ...otherParams } = params;
3939
return this.httpClient.get(`/podcasts/${id}`, {
40-
otherParams,
40+
params: otherParams,
4141
});
4242
};
4343

4444
this.fetchEpisodeById = (params) => {
4545
const { id, ...otherParams } = params;
4646
return this.httpClient.get(`/episodes/${id}`, {
47-
otherParams,
47+
params: otherParams,
4848
});
4949
};
5050

@@ -55,7 +55,7 @@ const Client = (config = {}) => {
5555
this.fetchCuratedPodcastsListById = (params) => {
5656
const { id, ...otherParams } = params;
5757
return this.httpClient.get(`/curated_podcasts/${id}`, {
58-
otherParams,
58+
params: otherParams,
5959
});
6060
};
6161

@@ -72,21 +72,21 @@ const Client = (config = {}) => {
7272
this.fetchRecommendationsForPodcast = (params) => {
7373
const { id, ...otherParams } = params;
7474
return this.httpClient.get(`/podcasts/${id}/recommendations`, {
75-
otherParams,
75+
params: otherParams,
7676
});
7777
};
7878

7979
this.fetchRecommendationsForEpisode = (params) => {
8080
const { id, ...otherParams } = params;
8181
return this.httpClient.get(`/episodes/${id}/recommendations`, {
82-
otherParams,
82+
params: otherParams,
8383
});
8484
};
8585

8686
this.fetchPlaylistById = (params) => {
8787
const { id, ...otherParams } = params;
8888
return this.httpClient.get(`/playlists/${id}`, {
89-
otherParams,
89+
params: otherParams,
9090
});
9191
};
9292

tests/PodcastApiTest.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ test('Test fetchPodcastById with mock', () => {
118118
const podcastId = 'abcde';
119119
return client.fetchPodcastById({
120120
id: podcastId,
121+
sort: 'oldest_first',
121122
}).then((response) => {
123+
expect(response.config.params.sort).toBe('oldest_first');
122124
expect(response.config.url).toBe(`/podcasts/${podcastId}`);
123125
expect(response.config.method).toBe('get');
124126
expect(response.data.episodes.length > 0).toBe(true);
@@ -132,8 +134,10 @@ test('Test fetchEpisodeById with mock', () => {
132134
const episodeId = 'abc222de';
133135
return client.fetchEpisodeById({
134136
id: episodeId,
137+
show_transcript: 1,
135138
}).then((response) => {
136139
expect(response.config.url).toBe(`/episodes/${episodeId}`);
140+
expect(response.config.params.show_transcript).toBe(1);
137141
expect(response.config.method).toBe('get');
138142
expect(response.data.podcast.rss.length > 0).toBe(true);
139143
}).catch(() => {

0 commit comments

Comments
 (0)