小编Yos*_*shy的帖子

SyntaxError:在 Angular8 中 JSON.parse 的位置 0 处出现意外的 JSON 标记 U

我只是避免了这个问题,直到最近当我更改以前代码的一些位和部分时,才注意到这个特定的错误。

\n\n

我使用 Angular 8、NodeJS、express 和 mongoose

\n\n

每当我尝试传递特定对象或该对象的一部分时,我都会收到此错误(来自 chrome 控制台):

\n\n
HttpErrorResponse {headers: HttpHeaders, status: 201, statusText: "Created", url: "http://localhost:3200/users/", ok: false, \xe2\x80\xa6}\nerror: {error: SyntaxError: Unexpected token U in JSON at position 0 at JSON.parse (<anonymous>) at XMLHtt\xe2\x80\xa6, text: "Updated successfully!"}\nheaders: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: \xc6\x92}\nmessage: "Http failure during parsing for http://localhost:3200/users/"\nname: "HttpErrorResponse"\nok: false\nstatus: 201\nstatusText: "Created"\nurl: "http://localhost:3200/users/"\n__proto__: HttpResponseBase\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是错误对象内部:

\n\n
message: "Unexpected token U in JSON at position 0"\nstack: "SyntaxError: Unexpected token U in JSON at …
Run Code Online (Sandbox Code Playgroud)

mongodb node.js typescript angular angular8

3
推荐指数
1
解决办法
5965
查看次数

标签 统计

angular ×1

angular8 ×1

mongodb ×1

node.js ×1

typescript ×1