Skip to content

TypeError: Failed to fetch #348

@sugandhhgoyal

Description

@sugandhhgoyal

`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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions