TypeError: Failed to fetch
sugandhhgoyal opened this issue · 1 comments
sugandhhgoyal commented
`import './App.css';
export default class ItemLister extends React.Component {
constructor() {
super();
this.state = { items: [] };
}
componentDidMount() {
fetch('https://www.getpostman.com/collections/1d8df8b0b5bf27e5009b').then(result=> {
console.log(result.json());
this.setState({items:result.json()});
}).catch(err => {
console.log(err);
this.setState({ items:[] });
});
}
render() {
return(
<div>
<div>Items:</div>
<div> { JSON.stringify(this.state.items)}</div>
</div>
);
}
}`
error-
Fetch API cannot load https://www.getpostman.com/collections/1d8df8b0b5bf27e5009b. The 'Access-Control-Allow-Origin' header has a value 'https://www.getpostman.com' that is not equal to the supplied origin. Origin 'http://localhost:3000' is therefore not allowed access. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
bundle.js:18335 TypeError: Failed to fetch
Foxandxss commented
Explain, I am reading React in here.