Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including hackerfire with all npm packages installed. Try it out:

var hackerfire = require("hackerfire")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

hackerfire v0.2.0

A node module to wrap around the Hacker News Firebase API

hackerfire

Simple Node module for the Hacker News Firebase API

Installation:

npm install hackerfire

Usage:

Get Top Stories:

var hackerfire = require('hackerfire');

hackerfire.getTopStories().then(function(response) {
  console.log(response);
});

Get User:

var user = hackerfire.getUserById('pg');

user.on('value', function(response) {
  console.log(response.val());
}, function(error) {
  console.log('retrieval failed: ' + error.code);
});

var users = hackerfire.getUserById([ 'pg', 'foobar' ]);

for(var i = 0; i < users.length; i++) {
  users[i].on('value', function(response) {
    console.log(response.val());
  }, function(error) {
    console.log('retrieval failed: ' + error.code);
  });
}

Get Item:

var item = hackerfire.getItem( '8265435' );

for(var i = 0; i < item.length; i++) {
  item.on('value', function(response) {
    console.log(response.val());
  }, function(error) {
    console.log('retrieval failed: ' + error.code);
  });
}

var items = hackerfire.getItem([ '8265435', '8168423' ]);

for(var i = 0; i < items.length; i++) {
  items.on('value', function(response) {
    console.log(response.val());
  }, function(error) {
    console.log('retrieval failed: ' + error.code);
  });
}

For more information on how firebase works for retrieving data, check out their docs: https://www.firebase.com/docs/web/guide/retrieving-data.html

Tests

npm install

gulp tests

Issues

Issues

License

MIT License

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free