Software engineering student focused on project management, with a strong dedication to continuous learning and development.
🚀 Software Engineer by day, SRE magician by night! ✨ Tech enthusiast with an insatiable curiosity for data. 📝 Harvard CS50 Undergrad igniting my passion for code. Currently delving into the MERN stack – because who doesn't love crafting seamless experiences from front to back? Join me on this exhilarating journey of embracing technology, penning insightful tech chronicles, and unraveling the mysteries of data! 🔍🔧 Let's build, let's write, let's explore – all aboard the tech express! 🚂🌟 #CodeAndCuriosity
Markdown supported · ⌘↵ to post
Abigeal Afolabi
Favourite Jome
It's funny how I also struggled to figure out why the first code snippet wasn't working 😅. I eventually had to use AI for help 🥲.
So without using the async syntax, which makes things easy to read and understand, the way to get the data from the resolved promise will be like this:
function getBadPokemon() { return fetch('pokeapi.co/api/v2/pokemon/pikachu') .then(response => response.json()) .then(data => { console.log(data); // Now you can see the pokemon return data; // Returns the pokemon data }) } getBadPokemon().then(pokemon => { console.log("Pokemon Data:", pokemon); });We return the promise from the fetch call, and then get the actual data here:
getBadPokemon().then(pokemon => { console.log("Pokemon Data:", pokemon); });