김건희

[Merge] 'feature/redux' into 'frontend'

......@@ -107,19 +107,19 @@ function RegisterPage(props) {
// 액션생성함수
dispatch(register(UserData));
registerResult.then((result) => {
console.log(result);
if (result.registerSuccess === '1') {
alert('회원 가입 완료!');
navigate('/login');
}
else if (result.registerSuccess === '0') {
alert('중복된 아이디 존재ㅠㅠ');
}
else {
alert('회원 가입 실패ㅜㅜ');
}
})
console.log(result);
if (result.registerSuccess === '1') {
alert('회원 가입 완료!');
navigate('/login');
}
else if (result.registerSuccess === '0') {
alert('중복된 아이디 존재ㅠㅠ');
}
else {
alert('회원 가입 실패ㅜㅜ');
}
})
};
......
import { combineReducers } from "redux";
import user from "./user.js";
import weather from "./weather";
const rootReducer = combineReducers({
user,
weather,
})
export default rootReducer;
\ No newline at end of file
......
......@@ -3,9 +3,9 @@ import axios from 'axios';
const USER_REGISTER = 'user/REGISTER';
const USER_LOGIN = 'user/LOGIN';
export function register(dataToSubmit) {
export async function register (dataToSubmit) {
const req = axios.post('http://localhost:4000/api/register', dataToSubmit)
const req = await axios.post('http://localhost:4000/api/register', dataToSubmit)
.then(res => res.data);
return {
......
import axios from "axios";
const WEATHER_ADDRESS = 'weather/ADDRESS';
const WEATHER_COORDINATE = 'weather/COORDINATE';
const WEATHER_TODAY_INFORMATION = 'weather/TODAY_INFORMATION';
export function address() {
const req = axios.post('http://localhost:4000/api/address')
.then(res => res.data);
return {
type: WEATHER_ADDRESS,
payload: req,
}
}
export function coordinate(dataToSubmit) {
const req = axios.post('http://localhost:4000/api/cordinate', dataToSubmit)
.then(res => res.data);
return {
type: WEATHER_COORDINATE,
payload: req,
}
};
export function information(dataToSubmit) {
const req = axios.post('http://localhost:4000/api/weather', 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, address: action.payload };
break;
case WEATHER_COORDINATE:
return { ...state, dot: action.payload };
break;
case WEATHER_TODAY_INFORMATION:
return { ...state, todayInformation: action.payload };
break;
default:
return state;
}
}
\ No newline at end of file