diff --git a/.env.example b/.env.example index e0f9351..11eb342 100644 --- a/.env.example +++ b/.env.example @@ -13,4 +13,4 @@ SENTRY_DSN = "" SENTRY_AUTH_TOKEN = "" SENTRY_ORG = "" SENTRY_PROJECT = "" -API_FALLBACK_DOMAIN = "" \ No newline at end of file +API_FALLBACK_DOMAIN = "https://" \ No newline at end of file diff --git a/src/api/status.ts b/src/api/status.ts index 32a56fb..8f2d482 100644 --- a/src/api/status.ts +++ b/src/api/status.ts @@ -141,7 +141,7 @@ export const statusAPI = async ( language: string | undefined, event: FetchEvent ): Promise => { - const conversation = await fetchConversation(status, event); + let conversation = await fetchConversation(status, event); let tweet = conversation?.globalObjects?.tweets?.[status] || {}; if (tweet.retweeted_status_id_str) { @@ -156,8 +156,8 @@ export const statusAPI = async ( if (conversation.timeline?.instructions?.length > 0) { // Try request again with fallback this time console.log('No Tweet was found, trying fallback in case of geo-restriction'); - const conversationFallback = await fetchConversation(status, event, true); - tweet = conversationFallback?.globalObjects?.tweets?.[status] || {}; + conversation = await fetchConversation(status, event, true); + tweet = conversation?.globalObjects?.tweets?.[status] || {}; if (typeof tweet.full_text !== 'undefined') { console.log('Successfully loaded Tweet, requiring fallback'); diff --git a/src/fetch.ts b/src/fetch.ts index e5eda06..da2cc79 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -125,7 +125,7 @@ export const twitterFetch = async ( } catch (e: unknown) { /* We'll usually only hit this if we get an invalid response from Twitter. It's uncommon, but it happens */ - console.error('Unknown error while fetching from API'); + console.error('Unknown error while fetching from API', e); event && event.waitUntil( cache.delete(guestTokenRequestCacheDummy.clone(), { ignoreMethod: true })