-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[염정훈] sprint12 #327
The head ref may contain hidden characters: "Next-\uC5FC\uC815\uD6C8-sprint12"
[염정훈] sprint12 #327
Changes from all commits
817a159
d762954
8b6bb48
54b11af
971dd3f
fddb08c
141d2ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,23 +46,8 @@ export const getArticlesComment = async ({ | |
} | ||
}; | ||
|
||
export const postLogin = async () => { | ||
try { | ||
const response = await axiosInstance.post(`/auth/signIn`, { | ||
email: "[email protected]", | ||
password: "92089208", | ||
}); | ||
|
||
const token = response.data.accessToken; | ||
localStorage.setItem("token", token); | ||
return token; | ||
} catch (err) { | ||
console.error("로그인 토큰 가져오기 오류"); | ||
} | ||
}; | ||
|
||
export const postArticlesImage = async (file: File) => { | ||
const token = localStorage.getItem("token"); | ||
const token = localStorage.getItem("userInfo"); | ||
|
||
if (!token) { | ||
console.error("Error Messages: 토큰이 없습니다."); | ||
|
@@ -84,7 +69,8 @@ export const postArticlesImage = async (file: File) => { | |
}; | ||
|
||
export const postArticles = async ({ image, content, title }: ArticlesAdd) => { | ||
const token = localStorage.getItem("token"); | ||
const token = localStorage.getItem("userInfo"); | ||
|
||
|
||
if (!token) { | ||
console.error("Error Messages: 토큰이 없습니다."); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { axiosInstance } from "./axiosInstance"; | ||
|
||
export type LoginType = { | ||
email: string, | ||
password: string, | ||
} | ||
|
||
export type SignUpType = LoginType & { | ||
nickname: string, | ||
passwordConfirmation: string, | ||
} | ||
|
||
export const postLogin = async ({email, password}: LoginType) => { | ||
try { | ||
const response = await axiosInstance.post('/auth/signIn', { | ||
email, | ||
password | ||
}) | ||
|
||
return response.data; | ||
} catch (err) { | ||
console.error("로그인 오류" + err) | ||
} | ||
} | ||
|
||
export const postSignUp = async ({email, nickname, password, passwordConfirmation }: SignUpType) => { | ||
try { | ||
const response = await axiosInstance.post('/auth/signUp', { | ||
email, | ||
nickname, | ||
password, | ||
passwordConfirmation | ||
}) | ||
|
||
return response; | ||
} catch (err) { | ||
console.error("회원가입 오류" + err) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ import "@/styles/global.css"; | |
|
||
import type { AppProps } from "next/app"; | ||
import Head from "next/head"; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
|
||
const queryClient = new QueryClient(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. query client를 useState의 state에 선언해두면 유저 마다 캐싱을 확실히 할 수 있다고 합니다. |
||
|
||
export default function App({ Component, pageProps }: AppProps) { | ||
return ( | ||
|
@@ -25,7 +28,9 @@ export default function App({ Component, pageProps }: AppProps) { | |
</Head> | ||
<Header /> | ||
<GlobalStyle /> | ||
<Component {...pageProps} /> | ||
<QueryClientProvider client={queryClient}> | ||
<Component {...pageProps} /> | ||
</QueryClientProvider> | ||
<Footer /> | ||
</> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isLoggedIn
과isLoggedOut
은 서로 상반되는 상태라 하나의 상태로 관리해도 될 것 같습니다.따로 상태를 선언하신 이유가 있을까요?
isLoggedIn
이 false이면 로그아웃인걸로 해도 될 것 같아요.