diff --git a/api/music.js b/api/music.js index 5e49cca3..90a6af54 100644 --- a/api/music.js +++ b/api/music.js @@ -4,15 +4,7 @@ export default async (request) => { const API_KEY_MUSIC = Netlify.env.get('API_KEY_MUSIC'); const params = new URL(request['url']).searchParams const key = params.get('key') - const weeks = params.get('weeks') - let weeksArr = [] - let weeksString - - if (weeks?.includes(',')) { - weeksArr = weeks.split(',') - } else { - weeksString = weeks - } + const week = params.get('week') if (!key) return new Response(JSON.stringify({ status: 'Bad request', @@ -33,13 +25,8 @@ export default async (request) => { 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'}) - scrobbleData.push(...weekData['data']) - }) - } else if (weeksString) { - const weekData = await scrobbles.get(weeksString, { type: 'json'}) + if (week) { + const weekData = await scrobbles.get(week, { type: 'json'}) scrobbleData.push(...weekData['data']) } else { const windowData = await scrobbles.get('window', { type: 'json'})