如何将图像数据响应转换为Imagebase64?

这是我的 api

https://besticon-demo.herokuapp.com/icon?url=facebook.com&size=80..120..200

当我在邮递员中测试这个时,我得到了 Image..但是我怎么能用axios. 我现在用 Axios 得到了很长的字符串(比如?PNG...)

那么我如何使用该响应来显示图像..

   axios.get(RequestURL, { withCredentials: false })
                .then(function (response) {
                    // handle success
                    console.log(response)
                    var b64Response = btoa(response.data) 
                    setImageServer('data:image/png;base64,' + b64Response) // not showing image
                })

尝试运行时也会出错 btoa

DOMException:无法在“Window”上执行“btoa”:要编码的字符串包含超出 Latin1 范围的字符。

HTML

 <img src={ImageServer}/>

以上是如何将图像数据响应转换为Imagebase64?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>