Created
April 19, 2022 20:39
-
-
Save felixrieseberg/2a28e9c0580817547db9eeca63e70d81 to your computer and use it in GitHub Desktop.
Hi Stripe friends!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const url = new URL('https://api.tidesandcurrents.noaa.gov/api/prod/datagetter'); | |
url.search = new URLSearchParams({ | |
station: '9414290', | |
product: 'water_temperature', | |
time_zone: 'lst', | |
units: 'english', | |
date: 'today', | |
application: 'GGTC', | |
format: 'json' | |
}).toString(); | |
fetch(url) | |
.then((response) => response.json()) | |
.then((result = {}) => { | |
console.log(`Loaded data`, result); | |
const data = result.data; | |
if (!data || !Array.isArray(data) || data.length < 1) { | |
smallText.textContent = `Failed to load water temperature.`; | |
return; | |
} | |
const latest = data[data.length - 1]; | |
const temperature = latest.v; | |
const time = latest.t; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment