weather.js
896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import axios from "axios";
const WEATHER_ADDRESS = 'weather/ADDRESS';
const WEATHER_TODAY_INFORMATION = 'weather/TODAY_INFORMATION';
export function coordinate(dataToSubmit) {
const req = axios.post('http://localhost:4000/api/address', dataToSubmit)
.then(res => res.data);
return {
type: WEATHER_ADDRESS,
payload: req,
}
};
export function information(dataToSubmit) {
const req = axios.post('http://localhost:4000/api/mainpage', dataToSubmit)
.then(res => res.data);
return {
type: WEATHER_TODAY_INFORMATION,
payload: req,
}
};
export default function (state = {}, action) {
switch (action.type) {
case WEATHER_ADDRESS:
return { ...state, dot: action.payload };
break;
case WEATHER_TODAY_INFORMATION:
return { ...state, todayInformation: action.payload };
break;
default:
return state;
}
}