Search code examples
jsonmean-stackregistrationangular9

Not able to find the property of an object in Angular9


I'm doing a full-stack project where I got an Object with two property "success" and "message", through API when I register the form.

But my Frontend which is in Angular is not being able to read the success property.

enter image description here

enter image description here


Solution

  • authService.registerUser returns an Observable, that's why you can subscribe to it. You should check, if the object passed in the returned Observable corresponds to the expected object (the one that contains the properties "success" and "message").

    If this is the case, you could try to access the property in the following way:

    if (!data['success']) {
      this.submitting = false
    }
    

    Otherwise you have to correct the code in order to handle the data according to its type.