I'm a programming beginner. . Now I'm having a problem that I struggle to solve ... I want to write a numeric data in the H2 tag that I import via API call. I have tried in various ways, making a console log the data exists but it seems that I am wrong something to richamarlo in H2. I seek help in understanding and resolving this error. Thank you
Code:
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title></title> <script> const intervalTime = 10 * 1000; const container = document.getElementsByClassName("u-text u-text-palette-3-base u-title u-text-3"); const endpoint = "https://*************/v0/*******/************************/collections/****************?offset=0&limit=unlikely"; function onInterval() { fetch(endpoint, { method: "GET", headers: { Authorization: "Bearer **********************" } }) .then((res) => res.json()) .then((data) => { const title = data.records.map((a) => { return{ close: (a.close) }; }); const lastClose = title[title.length - 1]; console.log(lastClose); }); } onInterval(); window.setInterval(onInterval, intervalTime); </script> </head> <body> <h2><p class="u-text u-text-palette-3-base u-title u-text-3"></p> </h2> </body> </html>
Comment