<commit_before>const AjaxDemo = React.createClass({

  getInitialState: function(){
    return {
      httpResponseData: []
    }
  },

  componentDidMount: function() {
    // Note that fetch is not part of React, it is just an external library to manage HTTP
    fetch('http://10.116.12.245:8080/ApiRestInterna/xema/v1/mesurades/metadades/estacions')
      .then(response => {
        return response.text()
      }).then(body => {
        this.setState({ httpResponseData: JSON.parse(body) });
      });
  },

  render: function(){
    return (
      <AjaxDemoViewer data={this.state.httpResponseData} />
    )
  }
});

const AjaxDemoViewer = React.createClass({

  getDefaultProps: function() {
    return {
      data: []
    }
  },

  render: function() {

    var items = this.props.data.map (
        (item, index) => (
            <div key={index}>
              {item.codi} : {item.nom}
            </div>
          )
      );

    return (
      <div>
       {items}
      </div>
    )
  }
});<commit_msg>Add some comments about Services in ajax-demo<commit_after>const AjaxDemo = React.createClass({

  getInitialState: function(){
    return {
      data: []
    }
  },

  componentDidMount: function() {
    // - IMPORTANT: it is considered a good practice to execute the interactions with external
    //   services (such as REST APIs) at this point
    // - Note that fetch is not part of React, it is just an external library to manage HTTP.
    //   This method should be encapsulated in a Service to be reused elsewhere. As the way to
    //   do it strongly depends on the chosen architecture, it has not been done in this example.
    fetch('http://10.116.12.245:8080/ApiRestInterna/xema/v1/mesurades/metadades/estacions')
      .then(response => {
        return response.text()
      }).then(body => {
        this.setState({ httpResponseData: JSON.parse(body) });
      });
  },

  render: function(){
    return (
      <AjaxDemoViewer data={this.state.data} />
    )
  }
});

const AjaxDemoViewer = React.createClass({

  getDefaultProps: function() {
    return {
      data: []
    }
  },

  render: function() {

    var items = this.props.data.map (
        (item, index) => (
            <div key={index}>
              {item.codi} : {item.nom}
            </div>
          )
      );

    return (
      <div>
       {items}
      </div>
    )
  }
});
{'fraction_non_alphanumeric': 0.13428451531682753, 'fraction_numerical': 0.01258917331095258, 'mean_word_length': 2.1041666666666665, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2051919', 'n_tokens_mistral': 770, 'n_tokens_neox': 726, 'n_words': 183}