0

I return the context and status code from Django rest API as follows

Admin.objects.get(email_id = request.data.get('email_id'), password = request.data.get('password'))
            context = {'resp' : 'Login details are valid..!'}
            return Response(context,status=status.HTTP_200_OK)

How can I access this status in angular?

I try this but I am getting undefined

this.apiCallService.admin_signup(fd).subscribe((response:any)=>
    {
      this.spinnerFlag = false;
      console.warn(response.status);
      ----------

How to fix this issue?

console.log() =>

{resp: 'Account created successfully...!'}
2
  • Can you please share what you get when you console.log(response)? Commented Sep 10, 2022 at 16:02
  • Okk i added...! Please check...! Commented Sep 10, 2022 at 16:39

1 Answer 1

1

you can write an interceptor and get all status code of all response from your backend.

if you just want to get status code of this api call you can return status code in json returned from your backend. for example in a try catch block:

in try:

context = {'resp' : 'Login details are valid..!', 'status':'200'}

in catch:

context = {'resp' : 'Login details are invalid..!', 'status':'500'}
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.