From 8e9357fca7dde59b99a357125bf1b2474f8b4039 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sat, 30 Mar 2024 15:37:18 -0700 Subject: [PATCH] chore: scrobbling --- api/music.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/music.js b/api/music.js index 8ee85bbe..8ef367cc 100644 --- a/api/music.js +++ b/api/music.js @@ -4,7 +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('key').split(',') + const weeks = params.get('key')?.split(',') if (!key) return new Response(JSON.stringify({ status: 'Bad request', @@ -26,8 +26,10 @@ export default async (request) => { scrobbleData.push(weekData['data']) }) } else { - const weekData = await scrobbles.get('window', { type: 'json'}) - scrobbleData.push(weekData['data']) + const windowData = await scrobbles.get('window', { type: 'json'}) + console.log(windowData) + console.log(scrobbleData) + scrobbleData.push(windowData['data']) } return new Response(JSON.stringify({ data: scrobbleData }),