Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A code snippet of a service object I created for the OtakuRisuto app in my portfolio
serializeAnime(includedGenres, animeData) {
// genres will be res.included anime will be
/* set an object where each key is a genreId and each value is the genre title this is
needed to avoid subsequent api calls to the kitsu api for genre data */
let genreObject = {} => {
return genreObject[] = genre.attributes.title
// create an array of anime objects with only the data necessary for our purposes.
let animeArray = []
animeData.forEach(anime => {
let animeObject = {};
animeObject = {
title: anime.attributes.canonicalTitle,
description: anime.attributes.description,
image_url: anime.attributes.posterImage.medium,
rating: anime.attributes.averageRating,
episode_count: anime.attributes.episodeCount,
// only return genreObject values that match the id of genres in the anime object from kitsu.
genre: => {
return genreObject[]
return animeArray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment