Last active
May 24, 2019 15:45
-
-
Save eroncardoso88/f05545acdf8ed28be04e2ae57b3751eb to your computer and use it in GitHub Desktop.
Async code getting an undefined result
This file contains 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
// final code for openweather.com app | |
// ********************************** | |
searchData = async () => { | |
// API call | |
let data = await fetch(link); | |
console.log('inside API'); | |
const res = await data.json(); | |
this.parseChecker(res); | |
}; | |
parseChecker = async (res) => { | |
if (res !== undefined) { | |
this.updateFromServer(res); | |
} else { console.log('error, data is undefined') } | |
}; | |
updateFromServer = (res) => { | |
let transitionObject = [...res.list] | |
const updatedArray = transitionObject.filter(function(city) { | |
return cities.indexOf(city); | |
}); | |
console.log(updatedArray); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
edit: issue i had
I'm trying to use testeLista as an object with the array 'list' on it. But it isn't. This is just the response from the server, not a json object