0.0.14 • Published 7 years ago

node-fanfics v0.0.14

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

node-fanfics

Installation

npm install node-fanfics

Usage

Fetching a story

const nodeFanfics = require('node-fanfics')

// Fetches story information
nodeFanfics.getInfo(storyId).then(function (info) {
    info.title // title of the story
    info.authorName // username of the author
    info.summary // summary of the story
    info.chapters // number of chapters in the story
    info.imgUrl // url of the story's cover image
    info.getChapters() // a promise yielding an array of chapters
    info.getChapters(startChapter, endChapter) // you only want certain chapters
}).catch(function (error) {
    // something wrong happened and the story wasn't fetched
})

// Fetches a chapter
nodeFanfics.getChapter(storyId, chapterNumber).then(function (chapter) {
    chapter.title // title of chapter
    chapter.content // contents of chapter
}).catch(function (error) {
    // something wrong happened while fetching the chapter
})

// Fetches all chapters from a story
nodeFanfics.getAllChapters(storyId, chapters).then(function (chapters) {
    // loop through the chapters
    for (let chapter of chapters) {
        chapter.title // title of chapter
        chapter.content // contents of chapter
    }
}).catch(function (error) {
    // something wrong happened while fetching the chapters
})

// Fetches information from author (you stalker)
nodeFanfics.getAuthorInfo(authorId).then(function (author) {
    author.name // name of the author
    author.profileText // author's profile
    author.imgUrl // url the author's profile picture
}).catch(function (error) {
    // something wrong happened while fetching author's profile
})

All functions return ES6 Promises. They can be used like this:

var storyInfo = await nodeFanfics.getInfo(storyId)
var chapter = await nodeFanfics.getChapter(storyId, chapterNumber)
var chapters = await nodeFanfics.getAllChapters(storyId, numberOfChapters)
var author =  await nodeFanfics.getAuthorInfo(authorId)
0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago