首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >react本机android错误SyntaxError:位置0处的JSON中存在意外标记

react本机android错误SyntaxError:位置0处的JSON中存在意外标记
EN

Stack Overflow用户
提问于 2018-07-18 13:26:06
回答 1查看 768关注 0票数 0

错误日志:

代码语言:javascript
复制
blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:55463 Possible Unhandled Promise Rejection (id: 0):
SyntaxError: Unexpected token  in JSON at position 0
SyntaxError: Unexpected token  in JSON at position 0
    at parse (<anonymous>)
    at tryCallOne (blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:21859:14)
    at blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:21960:17
    at blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:8761:21
    at _callTimer (blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:8650:9)
    at _callImmediatesPass (blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:8686:9)
    at Object.callImmediates (blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:8905:14)
    at MessageQueue.__callImmediates (blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:8239:18)
    at blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:8066:18
    at MessageQueue.__guardSafe (blob:http://localhost:8081/d0cb8da3-cbda-4352-940d-9ad7827bfee6:8223:11)

问题只出现在Android上,原生的react。我使用fetch,方法post。

示例代码:

代码语言:javascript
复制
fetch(config.server + "/api/districts", {
      method: "POST"
    })
      .then(res => res.json())
      .then(res => {
        this.setState({ districts: res.data });
      });
EN

回答 1

Stack Overflow用户

发布于 2018-07-19 13:16:06

只是后端编码有问题(没有BOM的UTF-8)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51394147

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档