Skip to content

Instantly share code, notes, and snippets.

@tarasowski
Last active February 7, 2025 12:19
Show Gist options
  • Save tarasowski/f24a1d47e56a65985252d9170b3a19ed to your computer and use it in GitHub Desktop.
Save tarasowski/f24a1d47e56a65985252d9170b3a19ed to your computer and use it in GitHub Desktop.
weatherapi
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
const location = req.query.location
const response = await fetch(`https://wttr.in/${location}?format=j1`)
//context.log(response)
const data = await response.json()
context.log(data)
if (location === undefined) {
return context.res = {
statusCode: 400,
body: "Bitte eine Location eingeben!!!"
}
} else {
return context.res = {
statusBody: 200,
body: JSON.stringify(data)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment