title: React - How to pass returned data from an exported function to a component?
body: <p>How can I pass data I receive from a get request pass over to a component? Whatever I tried wouldn't work but my thinking was as the code below shows..
  Thanks!</p>
  
  <pre><code>    export function data() {
          axios.get('www.example.de')
              .then(function(res) {
                  return res.data
              })
              .then(function(data) {
                  this.setState({
                      list: data
                  })
              })
      }
  
      import {data} from './api.js';
  
      class Test extends React.Component {
          constructor(props) {
              super(props);
              this.state = {
                  list: ""
              };
          }
  
          componentWillMount() {
              data();
          }
          render() {
              return &lt;p &gt; this.state.list &lt; /p&gt;
          }
      }
  </code></pre>