Last active
February 7, 2025 12:19
-
-
Save tarasowski/f24a1d47e56a65985252d9170b3a19ed to your computer and use it in GitHub Desktop.
weatherapi
This file contains hidden or 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
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