Installation
$ npm install hack-news
Usage
####Top Stories
The examples below show how to access the IDs of the top stories on Hacker News.
var hn = require('hack-news');
hn.allTopStories( (error, allTheStories) => {
if (error) {
console.log(error);
}
console.log(allTheStories);
});
hn.allTopStories().then(stories => {console.log(stories);});
hn.numberOfTopStories(10, (error, numberOfStories) => {
if (error) {
console.log(error);
}
console.log(numberOfStories);
});
hn.numberOfTopStories(10).then(numberOfStories => {console.log(numberOfStories);});
####New Stories
The examples below show how to access the IDs of the new stories on Hacker News.
var hn = require('hack-news');
hn.allNewStories( (error, allTheStories) => {
if (error) {
console.log(error);
}
console.log(allTheStories);
});
hn.allNewStories().then(stories => {console.log(stories);});
hn.numberOfNewStories(10, (error, numOfStories) => {
if (error) {
console.log(error);
}
console.log(numOfStories);
});
hn.numberOfNewStories(10).then(numOfStories => {console.log(numOfStories);});
####Ask, Show and Job Stories
The examples below show how to access the IDs of Ask, Show and Job stories on Hacker News.
var hn = require('hack-news');
hn.asjStories('ask', (error, asj) => {
if (error) {
console.log(error);
}
console.log(asj);
});
hn.asjStories('show').then(asj => {console.log(asj);});
hn.numbOfAsjStories('show', 10, (error, asj) => {
if (error) {
console.log(error);
}
console.log(asj);
});
hn.numbOfAsjStories('job', 10).then(asj => {console.log(asj);});
####IDs
The examples below show how to select a single story with its ID you can also use
the ID method with the other methods provided.
var hn = require('hack-news');
hn.storyWithId(002, (error, story) => {
if (error) {
console.log(error);
}
console.log(story);
});
hn.numberOfNewStories(10, (error, numOfStories) => {
var myArray = numOfStories;
hn.storyWithId(myArray[0], (error, story) => {
console.log(story);
});
});
hn.storyWithId(12303).then(story => {console.log(story);});
hn.numbOfAsjStories('job', 10).then(asj => {
var myArray = asj;
hn.storyWithId(myArray[6]).then(story => {console.log(story);});
});
This is it for now but stay tuned I will be adding a lot more.