Skip to content

Instantly share code, notes, and snippets.

@gisderdube
Last active March 22, 2019 10:54
Show Gist options
  • Save gisderdube/8d9c188c9786b31cd1d79dac12fe499d to your computer and use it in GitHub Desktop.
Save gisderdube/8d9c188c9786b31cd1d79dac12fe499d to your computer and use it in GitHub Desktop.
import axios from 'axios'
let myData = [{id: 0}, {id: 1}, {id: 2}, {id: 3}]
async function fetchData(dataSet) {
for(entry of dataSet) {
const result = await axios.get(`https://ironhack-pokeapi.herokuapp.com/pokemon/${entry.id}`)
const newData = result.data
updateData(newData)
console.log(myData)
}
}
function updateData(newData) {
myData = myData.map(el => {
if(el.id === newData.id) return newData
return el
})
}
fetchData(myData)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment