August 14, 2017
Angular HTTP Testing “SyntaxError: Unexpected token o in JSON at position 1”
tl:dr; Solve this Issue: Add the following line to your imports:
1 |
import { Response } from '@angular/http'; |
Full version: A common problem affecting many developers when writing tests for the Angular 4 HTTP service is the following stack trace. It occurs if you assemble an response using a the wrong class. The call of .json()
will throw the error.
1 |
"Unexpected token o in JSON at position 1" |
[…]
READ MORE