Sorry new to javascript , but i'm trying to do a fetch api. I'm able to do so, but i'm unable to get the data to use it. Below is the Html / javascript im using. It works. I can console.log and see the promise.
However, i'm unable to get the [[PromiseValue]] 442 value to i can use it in a calculation.
I changed my API on here so it won't work. thank you in advance.
<html>
<body>
<h1>my test</h1>
<h1><div id="currocc"></div></h1>
</body>
<script>
var y = fetch('https://display.safespace.io/value/live/489f3c')
.then((response) => response.json())
.then((val) => document.getElementById('currocc').textContent = val);
console.log(y)
</script>
</html>
from console -----
Promise {<pending>}
__proto__: Promise
[[PromiseStatus]]: "resolved"
[[PromiseValue]]: 442