Skip to content

Commit 2e63170

Browse files
author
AJ Hsu
committed
Fill up the method of fetching related artists resource for ArtistFetcher
1 parent a4c7757 commit 2e63170

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/api/ArtistFetcher.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,21 @@ export default class ArtistFetcher extends Fetcher {
7474
offset: offset
7575
})
7676
}
77+
78+
/**
79+
* Fetch related artists
80+
*
81+
* @param {number} [limit] - The size for one page.
82+
* @param {number} [offset] - The offset index for first element.
83+
* @return {Promise}
84+
* @example api.artistFetcher.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchRelatedArtists()
85+
* @see https://docs-en.kkbox.codes/v1.1/reference#artists-artist_id-relatedartists
86+
*/
87+
fetchRelatedArtists(limit = undefined, offset = undefined) {
88+
return this.http.get(ENDPOINT + this.artist_id + '/related-artists', {
89+
territory: this.territory,
90+
limit: limit,
91+
offset: offset
92+
})
93+
}
7794
}

test/apitest.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ describe('Api Begin to Test', () => {
218218
artistFetcher.fetchTopTracks().then(response => response.status.should.be.exactly(200), reject => should.not.exists(reject))
219219
})
220220
})
221+
222+
describe('#fetchRelatedArtists()', () => {
223+
it('should response status 200', (done) => {
224+
artistFetcher.fetchRelatedArtists().then(response => response.status.should.be.exactly(200), reject => should.not.exists(reject))
225+
})
226+
})
221227
})
222228

223229
describe('Artist fetch album tests', () => {

0 commit comments

Comments
 (0)