Thursday, 8 June 2017

React connection with node api

Got a problem with cors and react connection with the API, I've build width webkit dev server, react/redux and node API. I use express.js for the server part and cors.

The error is : Fetch API cannot load http://localhost:8080/api/passwords. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

const fetchPasswords = () => {
  return fetch('http://localhost:8080/api/passwords', {
    headers: new Headers({
      "Content-Type": "application/json"
    }),
  })
  .then(response => response.json());
};

Thank you for your help !



via Morgan Leroux

No comments:

Post a Comment