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);
 }
1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Adding that it has a problem with "options" in the post constructor, No overload matches this call

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.