chore: update music api
This commit is contained in:
parent
bc5bf79e5c
commit
1dd48ddf68
2 changed files with 22 additions and 13 deletions
11
api/music.js
11
api/music.js
|
@ -28,6 +28,11 @@ export default async (request) => {
|
|||
|
||||
const scrobbles = getStore('scrobbles')
|
||||
const scrobbleData = []
|
||||
const artists = getStore('artists')
|
||||
const albums = getStore('albums')
|
||||
const artistsMap = await artists.get('artists-map', { type: 'json' })
|
||||
const albumsMap = await albums.get('albums-map', { type: 'json' })
|
||||
|
||||
if (weeksArr.length > 0) {
|
||||
weeksArr.forEach(async (week) => {
|
||||
const weekData = await scrobbles.get(week, { type: 'json'})
|
||||
|
@ -41,7 +46,11 @@ export default async (request) => {
|
|||
scrobbleData.push(...windowData['data'])
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify({ data: scrobbleData }),
|
||||
return new Response(JSON.stringify({
|
||||
scrobbles: scrobbleData,
|
||||
artists: artistsMap,
|
||||
albums: albumsMap
|
||||
}),
|
||||
{ headers: { "Content-Type": "application/json" } }
|
||||
)
|
||||
}
|
||||
|
|
Reference in a new issue