diff --git a/services/soundcloud.ts b/services/soundcloud.ts index 10ca275..95d05df 100644 --- a/services/soundcloud.ts +++ b/services/soundcloud.ts @@ -15,12 +15,9 @@ console.log({ CLIENT_ID, CLIENT_SECRET }); export const getHeaders = async () => { let found = false; - let expired = false; const now = new Date().getTime(); - if (!found) { - const existing = await kv.get(kvkeys.expires_in); - if (existing.value && existing.value < now) expired = true; - } + const expiry_date = await kv.get(kvkeys.expires_in); + const expired = expiry_date.value ? expiry_date.value < now : true; if (!expired) { // Get existing headers const existing = await kv.get(kvkeys.headers);