fix(common): send flushed body as error instead of null

fix #18181
This commit is contained in:
jnizet
2017-07-17 21:16:27 +02:00
committed by Alex Rickabaugh
parent 256bc8acdd
commit 5c62e300e1
2 changed files with 14 additions and 5 deletions

View File

@ -61,12 +61,11 @@ export class TestRequest {
if (statusText === undefined) {
throw new Error('statusText is required when setting a custom status.');
}
const res = {body, headers, status, statusText, url};
if (status >= 200 && status < 300) {
this.observer.next(new HttpResponse<any>(res));
this.observer.next(new HttpResponse<any>({body, headers, status, statusText, url}));
this.observer.complete();
} else {
this.observer.error(new HttpErrorResponse(res));
this.observer.error(new HttpErrorResponse({error: body, headers, status, statusText, url}));
}
}