Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hekike/morphic-fetcher
Isomorphic fetcher which works on both client and server side
https://github.com/hekike/morphic-fetcher
Last synced: about 1 month ago
JSON representation
Isomorphic fetcher which works on both client and server side
- Host: GitHub
- URL: https://github.com/hekike/morphic-fetcher
- Owner: hekike
- License: mit
- Created: 2014-11-09T18:52:51.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-01T07:39:01.000Z (almost 10 years ago)
- Last Synced: 2024-04-14T20:10:22.864Z (7 months ago)
- Language: JavaScript
- Size: 188 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
morphic-fetcher
===============Isomorphic fetcher which works on both client and server side
[![Build Status](https://travis-ci.org/hekike/morphic-fetcher.svg?branch=master)](https://travis-ci.org/hekike/morphic-fetcher)
# 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) {
..
});
```