Skip to content

Commit

Permalink
Fix: user id response 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yongseong2 committed Nov 6, 2024
1 parent 95025a3 commit eba525c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
9 changes: 8 additions & 1 deletion src/api/login.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { instance } from './instance';

export const login = async (nickname: string, password: string) => {
interface LoginResponse {
userId: number;
}

export const login = async (
nickname: string,
password: string,
): Promise<LoginResponse> => {
const response = await instance.post('/users/login', { nickname, password });
return response.data;
};
2 changes: 0 additions & 2 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export const Home = () => {
return '';
}

console.log(seafoods);

useEffect(() => {
fetchSeafoods();
}, []);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Login = () => {
const handleLogin = async () => {
try {
const response = await login('김구름', '1234');
dispatch(setUserId({ userId: response }));
dispatch(setUserId({ userId: response.userId }));
} catch (error) {
console.error(error);
}
Expand Down
11 changes: 8 additions & 3 deletions src/store/modules/user.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';

interface UserInfo {
userId: string;
userId: number;
}

const initialState = {
userId: '',
export interface UserState {
userId: number | null;
isAuthenticated: boolean;
}

const initialState: UserState = {
userId: null,
isAuthenticated: false,
};

Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import react from '@vitejs/plugin-react-swc';

// https://vite.dev/config/
export default defineConfig({
base: '',
base: '/',
plugins: [react()],
server: {
port: 3000,
Expand Down

0 comments on commit eba525c

Please sign in to comment.