Skip to content
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

connect upload component's error to message #163

Merged
merged 9 commits into from
Dec 29, 2024
Merged

Conversation

yougyung
Copy link
Member

@yougyung yougyung commented Dec 15, 2024

πŸ“Œ μž‘μ—… λ‚΄μš©

κ΅¬ν˜„ λ‚΄μš© 및 μž‘μ—… ν–ˆλ˜ λ‚΄μ—­
#92

  • error code 반영
  • fetch -> fetch-ax 둜 request migration

πŸ€” κ³ λ―Ό ν–ˆλ˜ λΆ€λΆ„

성적 μ—…λ‘œλ“œ νŽ˜μ΄μ§€μ˜ error code 반영

  • ERROR_CODE에 μ •μ˜λ˜μ§€ μ•Šμ€ λ©”μ‹œμ§€λ„ μ„œλ²„μ—μ„œ μ „μ†‘ν•˜λŠ” κ²½μš°κ°€ μ‘΄μž¬ν•˜λ―€λ‘œ
    • errorCode && errorCode in ERROR_CODEκ°€ false인 κ²½μš°μ—λŠ” errorCodeλ₯Ό κ·ΈλŒ€λ‘œ λ…ΈμΆœν•©λ‹ˆλ‹€.
  • INVALIDATED_GRADUATION_CATEGORY, UNFITTED_GRADUATION_CATEGORY κ²½μš°λŠ”, κ²°κ³Ό 도메인과 κ΄€λ ¨λœ μ—λŸ¬μ΄μ§€λ§Œ μ‚¬μš©μžμ—κ²Œ λ…ΈμΆœ 될 κ°€λŠ₯성이 μ—†λ‹€κ³  νŒλ‹¨ν•΄ μ μš©ν•˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.

formdata μš”μ²­μ— λŒ€ν•œ 였λ₯˜

  • 문제 상황에 λŒ€ν•œ ν•΄κ²°μ±…
    • fetch-axμ—μ„œ [formdata μš”μ²­μ— λŒ€ν•΄ content type을 undefined둜 μ„€μ •]

상황

// 문제 λ°œμƒ μ½”λ“œ
export const parsePDFtoText = async (formData: FormData) => {
   const response= await fetch(API_PATH.parsePDFtoText, { method: 'POST', body: formData });
   return response.text();
};
  • parsePDFtoTextλŠ” formdataλ₯Ό λ‹΄μ•„ μš”μ²­μ„ 전솑
  • content-type을 multipart/form-data으둜 λ‹΄μ•„μ„œ μš”μ²­ν•˜λŠ” 경우, 500μ—λŸ¬λ₯Ό λ°˜ν™˜
    • multipart λ°μ΄ν„°μ—μ„œ 각 파트λ₯Ό κ΅¬λΆ„ν•˜λŠ” boundaryκ°€ μ‘΄μž¬ν•˜μ§€ μ•ŠκΈ° λ•Œλ¬Έμž„

fetch의 formdataμš”μ²­ λ°œμƒ μ‹œ

  • μ‚¬μš©μžμ˜ content-type μ„€μ • 없어도 Content-Type: multipart/form-data; boundary=<boundary> μ„€μ • 진행
  • μ‚¬μš©μžκ°€ 직접 Content-Type을 μ„€μ •ν•˜λ©΄ boundary λˆ„λ½μœΌλ‘œ μš”μ²­μ΄ μ‹€νŒ¨

-> λ”°λΌμ„œ fetch-ax도 μžλ™μœΌλ‘œ content-type이 μ„€μ •λ˜λ„λ‘ μœ λ„ν•˜κΈ° μœ„ν•΄ formdata μš”μ²­μ— λŒ€ν•΄ content type을 undefined둜 섀정을 λ³€κ²½ν•  κ³„νšμž…λ‹ˆλ‹€.

@yougyung yougyung self-assigned this Dec 15, 2024
seonghunYang
seonghunYang previously approved these changes Dec 16, 2024
Copy link
Collaborator

@seonghunYang seonghunYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€!

Comment on lines +37 to +41
getErrorMessage(): string {
const errorCode = this.response?.data?.errorCode;
if (!errorCode) return ERROR_CODE.INTERNAL_SEVER_ERROR;
return errorCode in ERROR_CODE ? ERROR_CODE[errorCode as keyof typeof ERROR_CODE] : errorCode;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Error κ°μ²΄μ—μ„œ μ—λŸ¬ λ©”μ‹œμ§€ μ²˜λ¦¬ν•˜λŠ” 방식 μ’‹λ„€μš”

Copy link
Member

@gahyuun gahyuun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

κ³ μƒν•˜μ…¨μ–΄γ…‡μš©

};
}
return await res.text();
return (await fetch(API_PATH.parsePDFtoText, { method: 'POST', body: formData })).text();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Myongji-Graduate/fetch-ax#25

이거 text ν•¨μˆ˜ ν•„μš” 없도둝 μˆ˜μ •ν•˜μ‹  κ±° μ•„λ‹Œκ°€μš©??

Copy link
Member Author

@yougyung yougyung Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ν•΄λ‹Ή μš”μ²­μ΄ PR에 μ„œμˆ ν•œ formdata μš”μ²­μ— λŒ€ν•œ 였λ₯˜λ¬Έμ œκ°€ λ°œμƒν•œ ν•¨μˆ˜μž…λ‹ˆλ‹€.
따라 fetch-ax에 변경사항이 μ—…λ°μ΄νŠΈ 되기 μ „κΉŒμ§€, fetch-ax둜 μ „ν™˜ν•˜λŠ” 것을 미루고 fetchλ₯Ό κ·ΈλŒ€λ‘œ μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€. ν•΄λ‹Ή μš”μ²­μ€ 응닡이 textν˜•μ‹μœΌλ‘œ μ „λ‹¬λ˜λ―€λ‘œ text()λ₯Ό 톡해 parsing을 μ§„ν–‰ν–ˆμŠ΅λ‹ˆλ‹€!

@yougyung yougyung merged commit 303f0dd into main Dec 29, 2024
1 of 3 checks passed
@yougyung yougyung deleted the result-fetch/#92 branch December 29, 2024 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants