0

i am trying to get the data from this api https://js.cexplorer.io/api-static/asset/list.json here is my code

let test2;
 fetch("https://js.cexplorer.io/api-static/asset/list.json")
  .then((res) => res.json())
  .then((res) => {
    console.log(res);
    test2 = res.data.policy;
  })
  document.getElementById("test3").innerHTML = test2;
console.log(test2)
; 

i have a div on homepage

<div id="test3" ></div>

i can fetch the data but when i try to display the policy(and other values) i got undefined on div and not the policy, i don't understand why

0 Answers0