我只是避免了这个问题,直到最近当我更改以前代码的一些位和部分时,才注意到这个特定的错误。
\n\n我使用 Angular 8、NodeJS、express 和 mongoose
\n\n每当我尝试传递特定对象或该对象的一部分时,我都会收到此错误(来自 chrome 控制台):
\n\nHttpErrorResponse {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\nRun Code Online (Sandbox Code Playgroud)\n\n这是错误对象内部:
\n\nmessage: "Unexpected token U in JSON at position 0"\nstack: "SyntaxError: Unexpected token U in JSON at …Run Code Online (Sandbox Code Playgroud)