获取上海的天气
接口:https://free-api.heweather.com/s6/weather/now?location=%E4%B8%8A%E6%B5%B7&key=db5af96d28554f55922cd41c51efd4f3
// 1. 设置
let locationCity = "上海"
$.get({
url: `https://free-api.heweather.com/s6/weather/now?location=${locationCity}&key=db5af96d28554f55922cd41c51efd4f3`,
dataType: "json",
success: (res) => {
dispatch({
type: "HAPPY_LIFE_WEATHER_STATE",
data: res
});
}
});
// 2. 获取的天气数据
{
HeWeather6: [
{
basic: {
cid: "CN101020100",
location: "上海",
parent_city: "上海",
admin_area: "上海",
cnty: "中国",
lat: "31.23170662",
lon: "121.47264099",
tz: "+8.00"
},
update: { loc: "2019-09-02 13:24", utc: "2019-09-02 05:24" },
status: "ok",
now: {
cloud: "75",
cond_code: "305",
cond_txt: "小雨",
fl: "27",
hum: "98",
pcpn: "0.2",
pres: "1014",
tmp: "23",
vis: "4",
wind_deg: "18",
wind_dir: "东北风",
wind_sc: "0",
wind_spd: "1"
}
}
]
}