Skip to content

Commit

Permalink
๐Ÿ› fix: get, post ์š”์ฒญ ์‹œ parse ๋Œ€์‹  safeParse ์‚ฌ์šฉ
Browse files Browse the repository at this point in the history
  • Loading branch information
baegyeong committed Nov 24, 2024
1 parent ded8dd0 commit f97cf06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/frontend/src/apis/utils/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ interface GetParams {
export const get = async <T>({ schema, url }: GetParams): Promise<T | null> => {
try {
const { data } = await instance.get(url);
const result = schema.parse(data);
const result = schema.safeParse(data);

if (!result.success) {
throw new Error(formatZodError(result.error));
}

return result;
return data;
} catch (error) {
if (process.env.NODE_ENV === 'development') {
console.error('API error:', error);
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/apis/utils/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export const post = async <T>({
}: PostParams): Promise<T | null> => {
try {
const { data } = await instance.post(url, { params });
const result = schema.parse(data);
const result = schema.safeParse(data);

if (!result.success) {
throw new Error(formatZodError(result.error));
}

return result;
return data;
} catch (error) {
if (process.env.NODE_ENV === 'development') {
console.error('API error:', error);
Expand Down

0 comments on commit f97cf06

Please sign in to comment.