Ich baue ein Projekt mit reagieren und redux, aber ich kann nicht mit meinem API
verbinden. Ich habe diese,Verbindung mit API - redux
componentDidMount() {
const {dispatch} = this.props;
dispatch(fetchByQuerystring());
}
und fetchByQuerystring
ist:
export function fetchByQuerystring() {
return function(dispatch) {
return fetch(`http://my_domain.dev/api`)
.then(response => response.json())
.then(json => dispatch(receiveByQuerystring(json)));
}
}
Wenn ich es laufen, bekomme ich diesen Fehler:
Fetch API cannot load http://my-domain.dev/api . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:3000 ' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Wie kann ich dieses Problem lösen?