无法解析Blob响应

时间:2018-12-11 08:34:14

标签: typescript angular-httpclient

我正在调用一个API,该API返回给我一个表示blob的图像,但是即使在get调用中传递了res​​ponseType之后,httpClient也无法解析响应。因为我要将ZPL中的数据发送到api,所以必须为此使用Content-Type作为标头中的“ application / x-www-form-urlencoded”。

var zpl =“ ^ xa ^ cfa,50 ^ fo100,100 ^ fdHello World ^ fs ^ xz”

var url =“ http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/” + zpl

httpHeaderOpt = httpHeaderOpt.append('Content-Type','application / x-www-form-urlencoded')

httpClient.get(URL,httpHeaderOpt,{observe:'response',responseType:'blob'})。subscribe(data => {  -对数据做点什么 })

此代码在解析http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/时始终抛出httpFailure。

响应状态为200。我熟悉angularJs,但这是我的第一个使用Angular 5的应用程序,非常感谢您的帮助。

0 个答案:

没有答案