How to use the isomorphic-fetch.Headers function in isomorphic-fetch

To help you get started, we’ve selected a few isomorphic-fetch 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 isomorphic-dev-js / complete-isomorphic-example / src / shared / products-action-creators.es6 View on Github external
export function getProducts() {
  const headers = new Headers({
    'Content-Type': 'application/json'
  });

  return (dispatch) => {
    return fetch('http://localhost:3000/api/products', {
      method: 'GET',
      headers
    }).then((response) => {
      return response.json().then((data) => {
        return dispatch({
          type: GET_PRODUCTS,
          notifications: data
        });
      });
    }).catch(() => {
      return dispatch({ type: `${GET_PRODUCTS}_ERROR` });
github r7kamura / stackable-fetcher / src / middlewares / mock.js View on Github external
_getHeaders() {
    let headers = new Headers(this.headers || {});
    if (headers.has('Content-Length')) {
      headers.set('Content-Length', this.body.length);
    }
    return headers;
  }