0

So in angular currently I make a post like this which receives the body of the HttpResponse as the response. How can I get the response to be the Http Response so I can view the status code and the body of the response?

How I currently do it. I am sending an array of my own Model "ValidationStep" and recieving an Array of ValidationStep

  saveListOfSteps(steps: ValidationStep[]): Promise<boolean> {
let httpHeaders = new HttpHeaders({
  'Content-Type' : 'application/json',
}); 
  let options = {
   headers: httpHeaders
  }; 
  return this.http.post<ValidationStep[]>(this.saveListOfStepsUrl, steps, options)
         .toPromise()
         .then(response => response as ValidationStep[])
         .catch(this.handleError);
 }
Daniel Haughton
  • 1,085
  • 5
  • 20
  • 45
  • Possible duplicate of [Angular 4.3.3 HttpClient : How get value from the header of a response?](https://stackoverflow.com/q/45505619/1260204) – Igor Oct 01 '19 at 10:46

1 Answers1

0
  let options = {
   headers: httpHeaders,
   observe: 'response'
  }; 

If I may add, do not convert your observables to promises. You're downgrading something that works wonderfully. Instead, learn how to use it, it's totally worth the time.