title: Call an API using superagent?
body: <p>I have an API that consists this branch of data</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>{
    "data": {
      "id": ,
      "title": ,
      "description": ,
      "old_price": "100",
      "new_price": "50",
      "size": "50",
      "quantity": 20,
    },
    "errors": null,
    "code": 1
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am using superagent in order to call the API and render this information, but I am doing it in wrong way. </p>
  
  <p>Here my code </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React from 'react';
  import {render} from 'react-dom';
  import superagent from 'superagent';
  import Layout from './components/Layout';
  
  class App extends React.Component{
    constructor(){
      super()
      this.state={
        name:''
      }
    }
      componentDidMount(){
          console.log('componentDidMount');
  
          const url='http://...';
          superagent
          .get(url)
          .query(null)
          .set('Accept', 'application/json')
          .end ((error, response)=&gt;{
              const title=response.body.response
              console.log(JSON.stringify(title));
              
              this.setState({
                name:title
              })
          })
          
      }
    render(){
      return(
        &lt;Layout data={this.state}/&gt;
      )
    }
  }
  
  
  render(&lt;App /&gt;, document.getElementById('app'));</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here I render it</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React from 'react';
  
  export default class Layout extends React.Component{
      render(){
          let data = this.props.data;
          return (
              &lt;div&gt; 
                   {data.name}
              &lt;/div&gt;
          )
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>But is not rendering, I think I am doing in wrong way. Please could you help me with that.</p>