Is there a way to adjust this promise code so that it throws an error whenever the response body contains an error code?
return this.httpService.post('/create', data)
.toPromise()
.then(response => response.json() as CreatedResponse)
.catch(this.handleCreateError);
I'm specifically looking to update the
.then(response => response.json() as CreatedResponse)
section to throw an error when response.json().hasError
is true. If not, the promise should simply resolve.