Skip to content

Conversation

@etture
Copy link

@etture etture commented Nov 27, 2025

EasyCodef SDK 클라이언트 requestProduct() 메서드 사용 시 post 요청의 응답이 파싱 불가한 형태로 들어오는 경우, API 응답을 promise resolve 하는 과정에서 JSON.parse() 가 SyntaxError를 발생, SDK를 이용하는 클라이언트 코드에서 catch 하지 못하는 형태의 에러가 발생하는 케이스가 있습니다.
따라서 해당 케이스를 방지하고자 JSON.parse() 로직을 try-catch로 감싸 promise 내부에서 에러를 처리하는 방식을 제안합니다.

재현 방법:

  • Endpoint: https://api.codef.io/v1/kr/etc/ld/kb/serial-number
  • Parameters: { organization: '0004', address: '시화호수전원2길 13-25' }
  • response.body: '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>400 Bad Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser sent a request that this server could not understand.<br />\n</p>\n</body></html>\n'

위 형태로 response.body가 들어올 경우 JSON.parse() 실패

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.

1 participant