analogcoding

blob type ? javascript 요청 본문

Be well coding/Mine

blob type ? javascript 요청

be well 2020. 1. 15. 16:04

blob은 Binary Large Object의 약자로 주로 이미지, 비디오, 사운드 등과 같은 멀티미디어 객체들을 의미합니다.

 

요청에 대한 error 를 alert 로 message 를 띄워주게 해놓았는데 반응이 없었다.

 

해당 요청이 성공하면 blob 형식에 file/zip을 받아와서 다운로드 하게 하는데 빈 값을 보내면 error 를 띄워주어야 하는 상황이지만

 

제대로 동작하지 않아서 찾던 와중 같은 이슈를 발견

 

https://github.com/axios/axios/issues/815

 

Error Response for blob type · Issue #815 · axios/axios

Hi, When the responseType is blob, the error response is converted into a blob as well. Is there a way to specify a different responseType for errors?

github.com

이에 대한 처리로는 위 링크에 방법들도 있지만 확실하게 error 가 나오는 상황에서는 responseType을 지정하지 않고 보내주고 ,

 

그 외에는 responseType : 'blob' 으로 전송하되 다른 오류를 고려해서 해당 값이 undefined 라면 다시 위처럼 전송해주는 식으로 해결!

 

Comments