UNPKG

anime-quotes-sdk

Version:

A Node.js SDK to fetch a random quote from a pre-fetched list of quotes.

42 lines (37 loc) 1.21 kB
const animeSDK = require("./animeSDK"); const apiUrl = ""; const sdk = new animeSDK(); // Properly chain the promises to ensure all quotes are fetched before attempting to retrieve specific quotes. sdk .fetchQuotes() .then(() => { sdk .getRandomQuote() .then((quote) => { console.log("Random Quote:", quote); }) .catch((err) => console.error("Failed to get random quote:", err)); sdk .getRandomQuotes(20) .then((quotes) => { console.log("Random 10 Quotes:", quotes); }) .catch((err) => console.error("Failed to get random 10 quotes:", err)); sdk .getQuotesByAnime("naruto", 20) .then((quotes) => { console.log("10 Quotes from Naruto:", quotes); }) .catch((err) => console.error("Failed to get 10 quotes from Naruto:", err) ); sdk .getRandomQuoteByAnime("naruto") .then((quote) => { console.log("Random Quote from Naruto:", quote); }) .catch((err) => console.error("Failed to get random quote from Naruto:", err) ); }) .catch((err) => console.error("Failed to fetch quotes:", err));