From f49846d4c5344024436da67bdb840c9ab80f901a Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Thu, 18 Aug 2022 03:58:25 -0400 Subject: [PATCH] Some tweaks to maybe make it work better --- src/fetch.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/fetch.ts b/src/fetch.ts index 7abb8ca..73d14bf 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -17,6 +17,10 @@ export const fetchUsingGuest = async ( { method: 'POST', headers: tokenHeaders, + cf: { + cacheEverything: true, + cacheTtl: 300 + }, body: '' } ); @@ -27,7 +31,6 @@ export const fetchUsingGuest = async ( `${Constants.TWITTER_API_ROOT}/1.1/guest/activate.json`, { method: 'GET', - headers: tokenHeaders, cf: { cacheEverything: true, cacheTtl: 300 @@ -145,10 +148,10 @@ export const fetchUsingGuest = async ( newTokenGenerated = true; continue; } - console.log('Caching guest token'); /* If we've generated a new token, we'll cache it */ - if (newTokenGenerated) { - event && event.waitUntil(cache.put(guestTokenRequestCacheDummy, activate.clone())); + if (event && newTokenGenerated) { + console.log('Caching guest token'); + event.waitUntil(cache.put(guestTokenRequestCacheDummy, activate.clone())); } conversation.guestToken = guestToken; return conversation;