小编Ale*_* Mo的帖子

如何修复“未捕获(承诺中)语法错误:位置 0 处 JSON 中出现意外标记 <”错误

经过几个小时的网络搜索后,我还没有找到解决我的问题的方法。所以我正在 React 和 Java Spring Boot 上构建一个全栈 CRUD 应用程序。到目前为止,我已经能够在 localhost://8080 上运行后端存储启动。当我在 localhost://3000 上运行前端 React 时出现问题 -> React 应用程序不断加载并且我看到\xe2\x80\x9cUncaught (承诺中) SyntaxError: Unexpected token < in JSON at 位置 0\xe2\x80\ x9d控制台中的错误。

\n

应用程序.js:

\n
import React, { Component } from \'react\';\nimport logo from \'./logo.svg\';\nimport \'./App.css\';\n\nclass App extends Component {\nstate = {\nisLoading: true,\ngroups: []\n};\n\nasync componentDidMount() {\nconst response = await fetch(\'/api/groups\');\nconst body = await response.json();\nthis.setState({ groups: body, isLoading: false });\n} ->\n
Run Code Online (Sandbox Code Playgroud)\n

此处出现语法错误

\n
render() {\nconst {groups, isLoading} = this.state;\n\nif …
Run Code Online (Sandbox Code Playgroud)

uncaught-exception reactjs spring-boot

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

reactjs ×1

spring-boot ×1

uncaught-exception ×1