Skip to content

Instantly share code, notes, and snippets.

Created July 13, 2020 12:09
What would you like to do?
const city = celestoryPoints.get('city', 'Paris');
const location = await fetch(`${city}`);
const locationData = await location.json();
if (locationData && locationData[0] && locationData[0].woeid) {
const woeid = locationData[0].woeid;
const weather = await fetch(`${woeid}`);
const weatherData = await weather.json();
if (weatherData && weatherData.consolidated_weather && weatherData.consolidated_weather.length > 0) {
celestoryPoints.set('city', city);
celestoryPoints.set('weather', weatherData.consolidated_weather[0].weather_state_name);
celestoryPoints.set('temperature', weatherData.consolidated_weather[0].the_temp);
celestoryPoints.set('city', city);
celestoryPoints.set('weather', 'NOT_FOUND');
celestoryPoints.set('temperature', 'NOT_FOUND');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment