1.0.0 • Published 9 years ago

morphic-fetcher v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 years ago

morphic-fetcher

Isomorphic fetcher which works on both client and server side

Build Status

Examples

Common / client

Check the example/simple-hapi/ directory and run with npm start after the npm install.

var Fetcher = require('morphic-fetcher');

var readUser = new Fetcher(server, {
  method: 'POST',
  host: 'http://localhost:3000',
  url: '/users/:user',
  param: {
    user: 'john'
  },
  query: {
    limit: 100
  },
  headers: {
    'content-type': 'application/json; charset=utf-8'
  },
  body: {
    foo: 'bar',
    bar: [1,2,3]
  }
}, function(res) {}
  console.log(res.status, res.body);
});

Server side

More framework is coming soon.

Hapi

var Hapi = require('hapi');
var server = new Hapi.Server();

var readUser = new Fetcher(server, { .. }, function (res) {
  ..
});
1.0.0

9 years ago

0.0.1

10 years ago