Skip to content

Instantly share code, notes, and snippets.

@bekatom
Created May 31, 2017 14:59
Show Gist options
  • Save bekatom/821ac1a8114eec4d187eae455c676db6 to your computer and use it in GitHub Desktop.
Save bekatom/821ac1a8114eec4d187eae455c676db6 to your computer and use it in GitHub Desktop.
Reducer example
/// gets data from service and maps each other creates new array
const getAllFestivals = (arr) => Promise.reduce(arr, (prev, item) =>
tkt.getShowsList({categoryId: item}).then((result) => {
if (result.data.Shows.length > 0) {
result.data.Shows.map((i) => {
prev.push(i)
})
}
return prev
}), [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment