my problem probably has an incredibly easy fix, but I'm new to javascript and can't seem to find an answer for it. Heres the script:
var proxyUrl = 'https://cors-anywhere.herokuapp.com/',
targetUrl = 'https://api.darksky.net/forecast/[key]/[latitude],[longitude]'
fetch(proxyUrl + targetUrl)
.then(blob => blob.json())
.then(data => {
console.log(data);
document.getElementById('weather').innerHTML = data;
})
However when i run it, the <p>
element doesnt change to the data itslef, it changes to "[object Object]" What am I doing wrong? Any help is appreciated.
PS: the targetUrl
variable has placeholders where the parameters go, it won't run as-is.
element?
– Sangwin Gawande Aug 18 '19 at 19:37