0

I implemented post method in angular 7. I want status code of post request.

I did following.

const sub = this.service.regEvent(this.pId, this.email)
      .subscribe(response => {
        console.log('response:', response);
        if(response.httpStatusCode === 200) {
        }
});

this.subscriptions.push(sub);

regEvent method

public regEvent(pId, email): Observable<any> {
    return this.http.post<any>(`this.endpointUrl?eventId=${pId}&email=${email}`,"").pipe(
      catchError(this.handleError)
    );
  }

Here console.log('response:', response); I am getting null.

In browser i checked and it's.

enter image description here

In postman also.

enter image description here

any help would be greatly appreciated.

1
  • It's unclear why you expected httpStatusCode to be there. That's not what the property is called even if you do read the full response as the docs tell you. If you used a better type than any to describe the actual response, the compiler could help you out. Commented Sep 13, 2019 at 10:57

1 Answer 1

1

You will need to observe response something like

this.http.post<any>(`this.endpointUrl?eventId=${pId}&email=${email}`,"",{observe: 'response'})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.