From 725637d281299976d12df4dbc1c8fef0987f11b1 Mon Sep 17 00:00:00 2001 From: 0xngmi <0xngmi@protonmail.com> Date: Mon, 3 Jul 2023 23:10:59 +0100 Subject: [PATCH] fix --- helpers/flipsidecrypto.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/helpers/flipsidecrypto.ts b/helpers/flipsidecrypto.ts index 78512e3a93..3469413c82 100644 --- a/helpers/flipsidecrypto.ts +++ b/helpers/flipsidecrypto.ts @@ -40,13 +40,18 @@ export async function queryFlipside(sqlQuery: string) { } catch(e:any){ if(e.response.statusText === 'Payment Required'){ if(API_KEY_INDEX < (FLIPSIDE_API_KEYS.length-1)){ - API_KEY_INDEX++; + const nextIndex = FLIPSIDE_API_KEYS.findIndex(k=>k===FLIPSIDE_API_KEY) + 1 + if(API_KEY_INDEX < nextIndex){ + API_KEY_INDEX = nextIndex; + } throw "Increasing API_KEY_INDEX"; } else { - bail(new Error(`Payment Required`)) + const error = new Error(`Payment Required`) + bail(error) + throw error } } - console.log("make query flipside", e) + console.log("make query flipside", e.response) throw e } }