title: Need to access a webapi server-side from a reactJS control
body: <p>I'm building a reactJS/aspnet5 site.  Where possible I'm trying to render my components serverside for responsiveness.  However I'd like to do an initial rendering, and then a more detailed rendering when a webapi call returns.  At the moment I have to fall back to client-side as follows:</p>
  
  <pre><code>class HomeComponent extends React.Component {
  
  constructor(props) {
      super(props);
      this.state = {firstname : "fetching..."};
  }
  
  componentWillMount() {
      if (typeof(XMLHttpRequest) != undefined) {
          var xhr = new XMLHttpRequest();
          xhr.open('get', '/Home/Me', true);
          xhr.onload = function() {
              var data = JSON.parse(xhr.responseText);
              this.setState(data);
          }.bind(this);
          xhr.send();
      }
  }
  
  render() {
      return (
        &lt;div&gt;
         &lt;h1&gt;Name&lt;/h1&gt;
            &lt;p&gt;{this.state.firstname} &lt;/p&gt; 
        &lt;/div&gt;
    );
  }
  
  }
  </code></pre>
  
  <p>What I'd like to be able to do is fulfill the request serverside or clientside, but XMLHttpRequest is, as I understand it, a browser facility.</p>
  
  <p>I've attempted to use request (<a href="https://www.npmjs.com/package/request" rel="nofollow">https://www.npmjs.com/package/request</a> ) but 2.69.0 fails to install and package correctly (npm and webpack, <em>on windows</em>), possibly due to a not-supported dependency, fs.</p>
  
  <p>Does anyone know of a windows-compatible method of doing http requests both client and serverside?</p>
  
  <p>Thanks</p>