Fetching contributors…
Cannot retrieve contributors at this time
84 lines (64 sloc) 2.03 KB


Interacting with Sparkart's Universe API, using SolidusClient! The Universe module inherits from the SolidusClient module.



var Universe = require('universe-js');
var universe = new Universe({key: '12345'});
universe.context = {...};


  • environment - The Universe API to use, choices are production and staging. Defaults to production.
  • key - The Universe API key to use.


Fetches the current fanclub and logged-in customer. If the instance's context already contains a resources.fanclub key, it is used instead of being fetched from the API. The callback argument is optional.

universe.init(function(err, data) {
  if (err) throw err;
  if (data.customer) {
    // The customer is logged in
universe.on('error', function(err) {
  throw err;
universe.on('ready', function(data) {
  if (data.customer) {
    // The customer is logged in

Callback arguments:

  • err - Error that occured while retrieving the resources.
  • data - Object containing the current fanclub and customer. customer is available only if the customer is logged in.

Emitted events:

  • error - Called with the same err argument as the callback.
  • ready - Called with the same data argument as the callback.


Same as solidus_client.render but the resources can be Universe endpoints.

var view = {
  resources: {
    events: '/events',
    other: ''
universe.render(view, function(err, html) {
  // ...


Fetch a resource. The URL can be a Universe endpoint.

universe.get('/events', function(err, data) {
  // ...


Post to a resource. The URL can be a Universe endpoint.'/account', {...}, function(err, data) {
  // ...