title: Fetch one JSON object and use it reactjs
body: <p>I'm very new to JS and ReactJS and I try to fetch an endpoint which gives me a JSON Object like this :</p>
  
  <pre><code>{"IDPRODUCT":4317892,"DESCRIPTION":"Some product of the store"}
  </code></pre>
  
  <p>I get this JSON Object by this endpoint :</p>
  
  <pre><code>http://localhost:3000/product/4317892
  </code></pre>
  
  <p>But I dont how to use it in my react application, I want to use those datas to display them on the page</p>
  
  <p>My current code looks like this but it's not working and I'm sure not good too :</p>
  
  <pre><code>import React, {Component} from 'react';
  
  class Products extends Component {
  
      constructor(props){
          super(props);
          this.state = {
              posts: {}
          };
      };
  
      componentWillMount() {
          fetch('http://localhost:3000/product/4317892')
              .then(res =&gt; res.json())
              .then(res =&gt; {
                  this.setState({
                      res
                  })
              })
              .catch((error =&gt; {
                  console.error(error);
              }));
      }
  
      render() {
          console.log(this.state)
          const { postItems } = this.state;
          return (
              &lt;div&gt;
                  {postItems}
              &lt;/div&gt;
          );
      }
  }
  
  export default Products;
  </code></pre>
  
  <p>In the console.log(this.state) there is the data, but I'm so confused right now, dont know what to do</p>
  
  <p>Since I'm here, I have one more question, I want to have an input in my App.js where the user will be able to type the product's id and get one, how can I manage to do that ? Passing the data from App.js to Products.js which is going to get the data and display them</p>
  
  <p>Thank you all in advance</p>