How to use the isomorphic-fetch.fetch 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
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` });
    });
  };
}