From 855786319394126061b16c443f908365cdafa904 Mon Sep 17 00:00:00 2001 From: Redume Date: Fri, 16 Feb 2024 16:34:15 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BA=D0=BE=D0=B4=D0=B0,=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BB=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BF=D0=B0=D0=BA=D1=82=D0=BD=D1=8B=D0=BC=20=D0=B8?= =?UTF-8?q?=20=D0=B1=D1=8B=D1=81=D1=82=D1=80=D1=8B=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/saveCourse.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/utils/saveCourse.js b/utils/saveCourse.js index 20ea1b6..6f55d82 100644 --- a/utils/saveCourse.js +++ b/utils/saveCourse.js @@ -5,17 +5,19 @@ const axios = require("axios"); const config = yaml.parse(fs.readFileSync("./config.yaml", "utf-8")); async function saveCourse() { - for (let i = 0; i < config['currency'].length; i++) { - for (let pair in config['currency'] ) { - const res = await axios.get( - `https://duckduckgo.com/js/spice/currency/1/${config['currency'][i]}/${config['currency'][pair]}` - ) - console.log(res.data) - - //TODO: добавить сохранение в бд - } - } + let pairs = []; + let currencies = ["USD", "RUB", "UAH", "JDF"] + config['currency'].forEach( + (value) => config['currency'].forEach(async (pair) => { + if(value !== pair) { + const res = await axios.get( + `https://duckduckgo.com/js/spice/currency/1/${value}/${pair}` + ) + console.log(res.data) + } + }) + ); }