Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bdhsu committed Jan 13, 2019
1 parent 3cac1e4 commit c41a91c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"axios": "^0.18.0",
"normalize": "^0.3.1",
"normalize.css": "^8.0.1",
"query-string": "^6.2.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-router-dom": "^4.3.1",
Expand Down
32 changes: 30 additions & 2 deletions src/Forecast.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
import React, { Component } from 'react';
// import { Link } from 'react-router-dom';
import queryString from 'query-string';
// components
import api from './utils/api';

class Forecast extends Component {
constructor(props) {
super(props);

this.state = {
location: null,
loading: true,
}
}
componentDidMount() {
var location = queryString.parse(this.props.location.search);
this.setState(_ => {
return {
location: location,
loading: false,
}
});
}
render() {
var location = this.state.location;
var loading = this.state.loading;

if(loading === true) {
return <div>loading...</div>
}
return (


<div className="container">
Forecast Component
{/* {JSON.stringify(location["city"])} */}
{JSON.stringify(api.fetchCurrentWeather(location["city"]))}
</div>
)
}
Expand Down
1 change: 0 additions & 1 deletion src/LocationInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { BrowserRouter as Router, Link } from 'react-router-dom';
import PropTypes from 'prop-types';

// components
import api from './utils/api';


class LocationInput extends Component {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ module.exports = {
var link = window.encodeURI(baseURL + "weather?q=" + location + params);
return axios.get(link)
.then(function(results) {
console.log('current weather results: ' + results);
// console.log('current weather results: ' + results);
console.log(JSON.stringify(results["data"]["weather"]));
console.log(results.data.weather);
return results.data.weather;
});
},
fetchFiveDayForecast: function(location) {
Expand Down

0 comments on commit c41a91c

Please sign in to comment.