Skip to content

Instantly share code, notes, and snippets.

@felixrieseberg
Created April 19, 2022 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixrieseberg/2a28e9c0580817547db9eeca63e70d81 to your computer and use it in GitHub Desktop.
Save felixrieseberg/2a28e9c0580817547db9eeca63e70d81 to your computer and use it in GitHub Desktop.
Hi Stripe friends!
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