如果response.data的值等于 Arraybuffer
需要进行转义
interceptors.response.use(
response => {
const enc = new TextDecoder('utf-8')
const data = JSON.parse(enc.decode(new Uint8Array(response.data)))
}
)
这篇博客讲述了如何在接收到ArrayBuffer类型的响应数据时,使用TextDecoder和JSON.parse进行数据转换。通过创建新的TextDecoder实例,以'utf-8'编码解码Uint8Array,并将解码后的结果解析为JSON对象,从而正确处理和解析服务器返回的数据。
如果response.data的值等于 Arraybuffer
需要进行转义
interceptors.response.use(
response => {
const enc = new TextDecoder('utf-8')
const data = JSON.parse(enc.decode(new Uint8Array(response.data)))
}
)
466
7437

被折叠的 条评论
为什么被折叠?