권주희

Update home.js

......@@ -31,6 +31,12 @@ export default class Home extends Component {
region: "은평구청",
curAirCondition: null,
routeInformation: null,
temperature: null,
humidity: null,
weather: null,
icon: null,
wind: null,
cloud: null,
};
}
......@@ -303,6 +309,35 @@ export default class Home extends Component {
.finally(function () {
// always executed
});
API.get("airCondition/weather", {
params: {
latitude: position["Ha"],
longitude: position["Ga"],
},
})
.then((response) => {
let resp = response["data"];
console.log(resp);
console.log("현재온도 : " + (resp.main.temp - 273.15));
console.log("현재습도 : " + resp.main.humidity);
console.log("날씨 : " + resp.weather[0].main);
console.log("상세날씨설명 : " + resp.weather[0].description);
console.log("날씨 이미지 : " + resp.weather[0].icon);
console.log("바람 : " + resp.wind.speed);
console.log("구름 : " + resp.clouds.all + "%");
this.setState({
temperature: (resp.main.temp - 273.15).toFixed(3),
humidity: resp.main.humidity,
weather: resp.weather[0].main,
icon: resp.weather[0].icon,
wind: resp.wind.speed,
cloud: resp.clouds.all + "%",
});
})
.catch(function (error) {
console.log(error);
});
};
let setDepart = document.createElement("Button");
setDepart.innerHTML = "출발지로 설정하기";
......@@ -400,7 +435,12 @@ export default class Home extends Component {
<br /> 미세먼지 등급 <br /> {pm10Image} <br />
미세먼지 지수 : {this.state.curAirCondition.pm10Value} <br />
초미세먼지 등급 <br /> {pm25Image} <br />
초미세먼지 지수 : {this.state.curAirCondition.pm25Value} <br />{" "}
초미세먼지 지수 : {this.state.curAirCondition.pm25Value} <br />
현재 온도 : {this.state.temperature} <br />
현재 습도 : {this.state.humidity} <br />
날씨 : {this.state.weather} <br />
바람 : {this.state.wind} <br />
구름 : {this.state.cloud} <br />{" "}
</h5>
);
}
......