1.1.1 • Published 8 years ago

isom-fetch v1.1.1

Weekly downloads
20
License
MIT
Repository
github
Last release
8 years ago

isom-fetch

Build Status

A isomorphic fetch for SSR and Koa.

Use in server

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

import fetch from 'isom-fetch';

const fetch = fetch.create({
  baseURL: '/api',
  headers: {}
});

fetch.get(`/user/${id}`);
fetch.post(`/user`, id);
1.1.1

8 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

0.0.1

8 years ago

1.0.0

8 years ago