preboot / angular-webpack

A complete, yet simple, starter for Angular v2+ using webpack
MIT License
1.29k stars 561 forks source link

TypeError: Failed to fetch #348

Open sugandhhgoyal opened 7 years ago

sugandhhgoyal commented 7 years ago

`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 7 years ago

Explain, I am reading React in here.