Skip to content

Result Type

This page deals with the JSON DB output as well as discussing the results or outputs of functions.

getAnime()

This function returns an Promise as such it’s an Asynchronous function needing to be await-ed.

The promise consists of an Object which has the relevant data of the anime(if any).

Data Structure of getAnime()
{
title: '....',
synopsis: '....',
episodes: '....',
url: 'https://myanimelist.net/anime/....',
genres: '....',
ratings: 'Average score based off ....',
image: 'https://cdn.myanimelist.net/images/anime/....',
year: 1234,
trailer: 'https://www.youtube.com/embed/....',
studio: '....',
recommendations: '....',
background: '....'
}

This function’s output can be accessed as such:

const db = require('anichu.db');
(async () => {
const res = await db.anime.get('sword art online'); // Refer the getAnime() page for usage
console.log(`${res.title} \n${res.year}`); // Like this
})();

searchAnime()

This function returns an Promise as such it’s an Asynchronous function needing to be await-ed.

The promise consists of an Array, having Objects as it’s elements. Each Object is the data returned by DB.

Data Structure of searchAnime()
[
{
title: '....',
synopsis: '....',
episodes: '....',
url: 'https://myanimelist.net/anime/....',
genres: '....',
ratings: 'Average score based off ....',
image: 'https://cdn.myanimelist.net/images/anime/....',
year: 1234,
trailer: 'https://www.youtube.com/embed/....',
studio: '....',
recommendations: '....',
background: '....'
}, {
title: '....',
synopsis: '....',
episodes: '....',
url: 'https://myanimelist.net/anime/....',
genres: '....',
ratings: 'Average score based off ....',
image: 'https://cdn.myanimelist.net/images/anime/....',
year: 1234,
trailer: 'https://www.youtube.com/embed/....',
studio: '....',
recommendations: '....',
background: '....'
}, { ... }
...
]

This function’s output can be accessed as such:

const db = require('anichu.db');
(async () => {
const res = await db.anime.search('sword art online', 0.6); // Refer the getAnime() page for usage
for (const e of res) { // Using loop cuz it returns array
console.log(`${e.title}\n${e.year}`); // Logs all anime titles in console as it returns
};
})();