Created
October 24, 2018 19:38
-
-
Save productioncoder/bb0bfbce5aef4b742a514e7e0f5fb51a to your computer and use it in GitHub Desktop.
Youtube video categories reducer function
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
function reduceFetchVideoCategories(response, prevState) { | |
const categoryMapping = response.items.reduce((accumulator, category) => { | |
accumulator[category.id] = category.snippet.title; | |
return accumulator; | |
}, {}); | |
return { | |
...prevState, | |
categories: categoryMapping, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment