How to use the traverson.from function in traverson

To help you get started, we’ve selected a few traverson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github traverson / traverson-hal / test / content_negotiation.js View on Github external
describe('Content negotiation', function() {

  var api
    , callback
    , firstUri
    , get
    , mockResponse
    , rootResponse
    , rootUri = 'http://api.io'
    , client = traverson.from(rootUri)
    , secondResponse
    , secondUri
    , thirdResponse;

  before(function() {
    traverson.registerMediaType(JsonHalAdapter.mediaType, JsonHalAdapter);
  });

  after(function() {
    // de-register HAL plug-in to leave Traverson in a clean state for other
    // tests
    traverson.registerMediaType(JsonHalAdapter.mediaType, null);
  });

  beforeEach(function() {
    api = client.newRequest();
github traverson / traverson-hal / test / localhost.js View on Github external
beforeEach(function() {
    jsonHalApi = traverson
      .from(rootUri)
      .jsonHal()
      .newRequest()
      .withRequestOptions({
      headers: {
        'Accept': 'application/hal+json',
        'Content-Type': 'application/json'
      }
    });
    callback = sinon.spy();
  });
github traverson / traverson-hal / test / json_hal.js View on Github external
before(function() {
    traverson.registerMediaType(JsonHalAdapter.mediaType, JsonHalAdapter);
    api = traverson.from(rootUri).jsonHal();
  });
github vtsukur / spring-rest-black-market / src / main / resources / static / js / controller / resource.js View on Github external
var config =  require("../config.js"),
    rootUri = config.rootUri,
    prefix = config.prefix,
    JsonHalAdapter = require("traverson-hal"),
    traverson = require("traverson"),
    api;

traverson.registerMediaType(JsonHalAdapter.mediaType,
    JsonHalAdapter);

api = traverson.from(rootUri);

module.exports = {
    getRootHal: function (callback) {
        api.jsonHal()
            .follow(prefix + "ads")
            .getUri(function (err, uri) {
                if (err) {
                    console.log(err);
                    return;
                }
                callback(uri);
            });
    },
    getFields: function (fields, callback) {
        var getField = function (fields, filedName) {
                return fields.filter(function (el) {
github vtsukur / spring-rest-black-market / src / main / resources / static / js / public / models / public.js View on Github external
var Backbone = require("backbone");
require("backbone-relational");
require("backbone-relational-hal");

var rootUri = "/",
    prefix = "currency-black-market:",
    JsonHalAdapter = require("traverson-hal"),
    traverson = require("traverson");


traverson.registerMediaType(JsonHalAdapter.mediaType,
    JsonHalAdapter);

var api = traverson.from(rootUri);
var resource = require("../../controller/resource.js");

var AdsModel = Backbone.RelationalHalResource.extend({
    initialize: function () {
        resource.getRootHal(function (halUrl) {
            this.halUrl = halUrl;
            this.fetch();
        }.bind(this));
    }
});

module.exports = AdsModel;
github vtsukur / spring-rest-black-market / src / main / resources / static / js / admin.js View on Github external
var $ = require("jquery");
var Backbone = require("backbone");
var Backform = require("backform");
var JsonHalAdapter = require("traverson-hal");
require("backbone-relational");
require("backbone-relational-hal");

var traverson = require("traverson");

traverson.registerMediaType(JsonHalAdapter.mediaType,
    JsonHalAdapter);

var rootUri = '/',
    api = traverson.from(rootUri),
    fields = [{
        name: "amount",
        label: "Количество:",
        control: "input",
        type: "number"
    }, {
        name: "currency",
        label: "Тип валюты:",
        control: "select"
    }, {
        name: "rate",
        label: "Курс:",
        control: "input",
        type: "number"
    }, {
        name: "type",

traverson

Hypermedia API/HATEOAS client for Node.js and the browser

MIT
Latest version published 2 years ago

Package Health Score

64 / 100
Full package analysis