добавлены регвест на апи ддг по парно к каждой валюте

This commit is contained in:
Данил 2024-02-15 22:19:33 +03:00
parent 868be0f39d
commit e21330bee7
2 changed files with 23 additions and 0 deletions

22
utils/saveCourse.js Normal file
View file

@ -0,0 +1,22 @@
const pool = require("../postgresql.js");
const yaml = require("yaml")
const fs = require("fs");
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: добавить сохранение в бд
}
}
}
module.exports = saveCourse;