Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/malcolmyu/isom-fetch
A isomorphic fetch for SSR and koa
https://github.com/malcolmyu/isom-fetch
Last synced: 27 days ago
JSON representation
A isomorphic fetch for SSR and koa
- Host: GitHub
- URL: https://github.com/malcolmyu/isom-fetch
- Owner: malcolmyu
- License: mit
- Created: 2016-06-08T09:49:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-28T07:17:07.000Z (over 8 years ago)
- Last Synced: 2024-10-13T13:02:24.447Z (about 1 month ago)
- Language: JavaScript
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# isom-fetch
[![Build Status](https://travis-ci.org/malcolmyu/isom-fetch.svg?branch=master)](https://travis-ci.org/malcolmyu/isom-fetch)
A isomorphic fetch for SSR and Koa.
## Use in server
```js
import isomFetch from 'isom-fetch';
import router from '../router';app.use(router);
app.use(function* (next) {
const location = this.originalUrl;
match({ routes, location }, (
error, redirectLocation, renderProps
) => {
const fetch = isomFetch.use(this, router);
// begin SSR
if (renderProps) {
render();
fetch.all(() => {
// SSR actually
render();
});
}
});
});
```## Use in client
```js
import fetch from 'isom-fetch';const fetch = fetch.create({
baseURL: '/api',
headers: {}
});fetch.get(`/user/${id}`);
fetch.post(`/user`, id);
```