I am trying to display specific data (local time, swell, wind, temperature) from a JSON array from an API call. I don't need all the data but I'm not sure how to only get the info I need and make it appear in a table on the browser.
Right now I'm getting all the JSON data in my console and I can display the entire string in on the browser.
var proxyUrl = 'https://cors-anywhere.herokuapp.com/',
targetUrl ='http://magicseaweed.com/api/0491dd8a14784887e8e150d44fea9953/forecast/?spot_id=867&fields=timestamp,localTimestamp,swell.*,wind.*,condition.temperature'
fetch(proxyUrl + targetUrl)
.then(blob => blob.json())
.then(data => {
console.table(data);
document.querySelector("pre").innerHTML = JSON.stringify(data, null, 2);
return data;
})
.catch(e => {
console.log(e);
return e;
});