Socket
Socket
Sign inDemoInstall

firebase-client

Package Overview
Dependencies
48
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    firebase-client

A simple Node.js client for Firebase


Version published
Weekly downloads
36
decreased by-7.69%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

firebase-client

Build Status NPM version Downloads/month

A simple Firebase client for Node.js, based on the firebase gem, by oscardelben.

## Installation

npm install firebase-client

Then, in your project require and instantiate the Firebase client:

var FirebaseClient = require('firebase-client');
var firebase = new FirebaseClient({
  url: "https://node-firebase-client.firebaseio.com/",
  auth: "my-auth-token"
});

Example Usage

GET

Gets the value of a resource at the specified path. Returns a promise, resolved on a successful HTTP response, or rejected on a client/server error.

firebase.get(path);
Example

To get the "example" resource:

firebase
.get('example')
.then(function(body){
  console.log(body);
})
.fail(function(err){
  console.log(err);
});

To get all resources withing your Firebase instance:

firebase
.get()
.then(function(body){
  console.log(body);
})
.fail(function(err){
  console.log(err);
});

SET

Set the value of a resource at the specified path. Returns a promise, resolved on a successful HTTP response, or rejected on a client/server error.

firebase.set(path, data);
Example
firebase
.set('example', { value: true })
.then(function(body){
  console.log(body); // returns { value: true }
})
.fail(function(err){
  console.log(err);
});

PUSH

Creates a new child resource under the specified path. Returns a promise, resolved on a successful HTTP response, or rejected on a client/server error.

firebase.push(path, data);
Example
firebase
.push('user', { email: 'test@example.com' })
.then(function(body){
  console.log(body); // returns name ref, e.g. { name: "-JR-fhuV6T3vkTNSVrBs" }, of the child resource
})
.fail(function(err){
  console.log(err);
});

UPDATE

Updates an existing resource at the specified path. Returns a promise, resolved on a successful HTTP response, or rejected on a client/server error.

firebase.update(path, data);
Example
firebase
.update('example', { value: true })
.then(function(body){
  console.log(body); // returns { value: true }
})
.fail(function(err){
  console.log(err);
});

DELETE

Removes resource at specified path. Returns a promise, resolved on a successful HTTP response, or rejected on a client/server error.

firebase.delete(path);

#### Example

firebase
.delete('example')
.then(function(){
  console.log(); // returns empty body, i.e. null
})
.fail(function(err){
  console.log(err);
});

More Info

For more information, check out the Firebase API docs.

Keywords

FAQs

Last updated on 13 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc