From f6d6be023b8ef8e06f7b6dd6dd5dba1402c0fc6e Mon Sep 17 00:00:00 2001 From: Redume Date: Fri, 2 Aug 2024 21:52:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BB?= =?UTF-8?q?=D1=8E=D1=87=D0=B5=D0=B9=20API=20coinapi=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=BD=D0=BE=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- collect-currency/save_crypto.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/collect-currency/save_crypto.js b/collect-currency/save_crypto.js index ff3fa76..3d78fbe 100644 --- a/collect-currency/save_crypto.js +++ b/collect-currency/save_crypto.js @@ -4,22 +4,22 @@ const pool = require('../database/postgresql.js'); function save_fiat() { if (!config['currency']['collecting']['crypto']) return; - const depth = config['currency']['cryptoKeys'] + const depth = config['currency']['coinapiKeys'] if (depth <= 0) new Error('Rate limit on all API tokens'); config['currency']['crypto'].forEach( (value) => config['currency']['crypto'].forEach(async (pair) => { if (value !== pair) { - const cryptoKeyActive = [0]; + const coinapiKey = [0]; const res = await axios.get(`https://rest.coinapi.io/v1/exchangerate/${value}/${pair}`, { timeout: 3000, headers: { - 'X-CoinAPI-Key': config['currency']['cryptoKeys'][cryptoKeyActive[0]], + 'X-CoinAPI-Key': config['currency']['coinapiKeys'][coinapiKey[0]], } }); - if (res.status === 429) rotate_key(config['currency']['cryptoKeys'], cryptoKeyActive); + if (res.status === 429) rotate_key(config['currency']['coinapiKeys'], coinapiKey); const data = res.data; const point = data['rate'].toString().indexOf('.') + 4;