There is a simple API on URL localhost:3001/swags with a few items and now I want to display them in a very simple REACT APP.
This is my REACT APP:
import React, { Component } from 'react';
class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      swags: null
    };
  }
  componentDidMount() {
    fetch('http://localhost:3001/swags')
      .then(response => response.json())
      .then(data => this.setState({ swags: data }));
  }
  render() {        
    return (
      <div><pre>{JSON.stringify(this.state, null, 2) }</pre></div>
    );
  }
}
export default App;
The Output on localhost:3000 ist an empty Object
{
  "swags": null
}
postman show me this output under this URL http://localhost:3001/swags
[
    {
        "id": 1,
        "title": "Item 1",
        "description": "Lorem ipsum dolor sit amet"
    },
    {
        "id": 2,
        "title": "Item 2",
        "description": "sed diam nonumy eirmod tempor"
    },
    {
        "id": 3,
        "title": "Item 3",
        "description": "takimata sanctus est Lorem ipsum dolo"
    }
]
Can anyone explain why the output of my simple App ist an empty object?
 
    