Can I update a variable value during an async API ...
# 🤝help
f
I created a code block to query some information from API, and i used an async function and updated the value of a workflow variable in side the async function. and tried to print out the vairbale rigth afterwards but find that vairable to be empty, while in the log i can see that variable was assigned a value. do you know why that is the case? the line of my code is: workflow.weatherDescription = weatherDescription; Below is my code: const lat = '43.49' const lon = '-80.53' const apiKey = 'df715295314c6e564a351abf1dc73787' const url =
https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}¤t_weather=true&hourly=weathercode
async function fetchData(url) { const response = await axios.get(url) const weatherData = response.data.current_weather console.log('---->weather', JSON.stringify(weatherData, null, 2)); const weatherCode = weatherData.weathercode const weatherDescription = weatherCode; workflow.weatherDescription = weatherDescription; console.log('---->session weather description', workflow.weatherDescription); // return weatherData } console.log(fetchData(url));

https://cdn.discordapp.com/attachments/1144456970443694100/1144456970686976010/CleanShot_2023-08-24_at_22.20.052x.png

7 Views