var Backbone = require('backbone');
var Promise = require('bluebird');
var parser = require('./lib/parser');

module.exports = {
  /**
   * Return Promise that resolves the API
   */
  create: function (_url, ns) {
    var ModelCollection = Backbone.Collection.extend({
      url: function () {
        return _url || this.document.url() + '/backbonemodel';
      }
    });
    var collection = new ModelCollection();

    return new Promise(function (resolve, reject) {
      collection.fetch({
        success: function (collection, response) {
          resolve(parser.parse({
            models: response,
            version: '0'
          }, ns));
        },
        error: function (error) {
          reject(new Error(error));
        }
      });
    });
  }
};

@@ -7,16 +7,35 @@
 ckbone =
+ global.Backbone %7C%7C
  require
@@ -742,15 +742,31 @@
 ror(
+JSON.stringify(
 error))
+)
 ;%0A  

improve error message