0
点赞
收藏
分享

微信扫一扫

Uncaught (in promise) TypeError: Failed to execute ‘setRequestHeader‘ on ‘XMLHttpRequest‘: String co

山竹山竹px 2022-04-14 阅读 205
ajax前端

问题:axios设置headers时,报错Uncaught (in promise) TypeError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': String contains non ISO-8859-1 code point.
原因是header中,不能使用中文

解决:对参数值进行编码
                // 编码 encodeURIComponent(str) // 解码 decodeURIComponent(str)


           后台进行接收:
                //编码 java.net.URLEncoder.encode(token,"UTF-8") //解码 java.net.URLDecoder.decode(token,"UTF-8")

举报

相关推荐

0 条评论