Answer the question
In order to leave comments, you need to log in
How to display currency price from json to html?
I have a link to a JSON file that contains exchange rates, but I only need to display the price in HTML.
In HTML, I still know something, but with JavaScript everything is very bad. I would be very grateful if you help.
Link: https://bank.gov.ua/NBUSStatService/v1/statdirector...
Answer the question
In order to leave comments, you need to log in
You can use fetch() - https://developer.mozilla.org/ru/docs/Web/API/Fetc...
Then extract the necessary information on the exchange rate from the received JSON (find the required field) and insert the data into HTML :
https://html5css.ru/js/js_htmldom_html.php
https://learn.javascript.ru/modifying-document
https://learn.javascript.ru/dom-nodes
Something like this:
fetch('https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?json').then(response => {
return response.json();
}).then(array => {
// проходимся по всем курсам валют в цикле
for (const item of array) {
// вставить курс в HTML, см. ссылки выше
// инфа о курсе находится в объекте item
console.log(item.txt + ': ' + item.rate);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question