Skip to content

Instantly share code, notes, and snippets.

@htunnicliff
Created August 8, 2018 15:02
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 htunnicliff/d6369ac8ba83d7259a8504740b1b06fa to your computer and use it in GitHub Desktop.
Save htunnicliff/d6369ac8ba83d7259a8504740b1b06fa to your computer and use it in GitHub Desktop.
async function weather(key, ...args) {
const url = `https://api.darksky.net/forecast/${key}/` + args.join(',')
const config = {
credentials: "same-origin",
mode: 'no-cors',
method: "GET",
headers: {
'Accept': 'application/json'
}
}
console.log(`Querying "${url}"`)
try {
const json = await fetch(url, config).then(res => res.json())
return json
} catch (err) {
console.log(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment