import React, { Component } from 'react';
import '../../App.css';
let request = require('superagent');

const location =
  {
    name: 'Göteborg',
    coordinates: '57.696994,11.9865'
  };

class Weather extends Component {

  constructor(props) {
    super(props);
    this.state = {
      result: []
    }
  }

  fetchData() {
    request
      .get(this.props.url + '/darksky/' + location.coordinates)
      .accept('json')
      .end( (err, res) => {
        if (res) {
          res = JSON.parse(res.text);
          this.setState({
            result: res
          });
        }
      });
  }

  componentWillMount() {
    this.fetchData();
  }

  componentDidMount() {
     window.setInterval(function() {
      this.fetchData();
    }.bind(this), 3600000);
  }

  render() {
    return (
      <div className="widget weather">
        Weather goes here
        <a href="https://darksky.net/poweredby/">Powered by Dark Sky</a>
      </div>
    );
  }
}

export default Weather;

@@ -97,16 +97,59 @@
 ent');%0A%0A
+// location format: %5Blatitude%5D,%5Blongitude%5D%0A
 const lo

add comment describing location format