Created
July 15, 2023 04:39
-
-
Save business24ai/d543b5782a764c761dbd5d92a8517796 to your computer and use it in GitHub Desktop.
Flowise get_the_current_weather_of_a_location
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
/* | |
* You can use any libraries imported in Flowise | |
* You can use properties specified in Output Schema as variables. Ex: Property = userid, Variable = $userid | |
* Must return a string value at the end of function | |
*/ | |
const fetch = require('node-fetch'); | |
const url = 'https://api.open-meteo.com/v1/forecast?latitude=' + $latitude + '&longitude=' + $longitude + '¤t_weather=true'; | |
const options = { | |
method: 'GET', | |
headers: { | |
'Content-Type': 'application/json' | |
} | |
}; | |
try { | |
const response = await fetch(url, options); | |
const text = await response.text(); | |
console.log('---< Weather function >---'); | |
console.log(text); | |
return text; | |
} catch (error) { | |
console.error(error); | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment