Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Created October 24, 2018 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/bb0bfbce5aef4b742a514e7e0f5fb51a to your computer and use it in GitHub Desktop.
Save productioncoder/bb0bfbce5aef4b742a514e7e0f5fb51a to your computer and use it in GitHub Desktop.
Youtube video categories reducer function
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