Skip to content

Commit

Permalink
refactor: apple api 코드 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
syoung125 committed Sep 4, 2023
1 parent be677c4 commit c1387e9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/pages/api/redirect/apple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import { ACCESS_TOKEN_KEY, REFRESH_TOKEN_KEY } from '@/shared/constants';
import { setAccessToken, setRefreshToken } from '@/shared/utils/auth';
import { generateUrl } from '@/shared/utils/generateUrl';

const appleLoginCallback = (code: string, name?: string, email?: string) => {
const appleLoginCallback = (data: {
code: string;
name?: string;
email?: string;
}) => {
return axios({
baseURL: NEXT_PUBLIC_API_BASE_URI,
url: generateUrl({ url: '/apple' }),
method: 'post',
validateStatus: null,
headers: { 'Content-Type': 'application/json' },
data: { code, name, email },
data,
});
};

Expand All @@ -32,9 +36,7 @@ export default async function handler(
}

try {
let response;
if (name && email) response = await appleLoginCallback(code, name, email);
else response = await appleLoginCallback(code);
const response = await appleLoginCallback({ code, name, email });

const {
[ACCESS_TOKEN_KEY]: accessToken,
Expand Down

0 comments on commit c1387e9

Please sign in to comment.