Trying to fetch JSON data from this API and it is failing. Any ideas on what I need to fix?
I am getting the following error:
Access to fetch at 'https://te-e10app01/ERP10/api/v1/Erp.BO.CustomerSvc/Customers' from origin 'http://localhost:3000' has been blocked by CORS policy.....
And error:
Failed to load resource: net::ERR_FAILED
import React, { Component } from 'react';
import Customers from './components/customers';
class App extends Component {
render() {
return (
<Customers customers={this.state.customers} />
);
}
state = {
customers: []
}
componentDidMount() {
fetch('https://te-e10app01/ERP10/api/v1/Erp.BO.CustomerSvc/Customers', {
headers: {
"Access-Control-Allow-Origin": "*",
"Authorization": "Basic ##################"
}
})
.then(res => res.json())
.then((data) => {
this.setState({ customers: data })
})
.catch(console.log)
}
}
export default App;