Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix property does not exist on type 'Object' in ionic 3?

I have call the API for get the data and but I got error Property sellerDto does not exist on type Object in ionic3 and I will try to declare the data as declared object but again same error occur how to fix this error?

/*
  @Copyright Notice:
  @(#)
  @Type: TS	
  @For:  create-accont.html.
  @Description : userLoggedInSuccess for create the user account 1st in the GCP 
 */
 public userData       : any = {};
userLoggedInSuccess(userObject) {
    //Enable the loader after call the FB function
    var self = this;
    //Declare the local variable
    self.url                  = "";
    self.API_HOST             = "";
    self.paramData                 = "";
    let userTypeKeyId = userObject.uid;

    let url = self.API_HOST + "/api/login/dto";
    let paramData  = "userTypeKeyId=" + userTypeKeyId;

    let headers =  {
      headers: new  HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded'})
    };

    //Pass the data into the API for check email is exist in the API or not
    self.http.post(url, paramData, headers).subscribe(data => {
      this.userData = data;
      if(this.userData.isLoggedIn) {
          //Here we will set the user Detail into the local-storage
          if(this.userData.userType == "seller" && this.userData.sellerDto == undefined){
            self.localStorage.set("defaultLanguage",    data.sellerDto.userTypeDto.defaultLanguage);
          }
        } else {
          console.log("user is no valid");
        }
  });
}
like image 380
Kapil Soni Avatar asked Mar 16 '18 08:03

Kapil Soni


1 Answers

Try typing the variable data :any

 self.http.post(url, paramData, headers).subscribe((data:any) => {
      this.userData = data;
      if(this.userData.isLoggedIn) {
          //Here we will set the user Detail into the local-storage
          if(this.userData.userType == "seller" && this.userData.sellerDto == undefined){
            self.localStorage.set("defaultLanguage",    data.sellerDto.userTypeDto.defaultLanguage);
          }
        } else {
          console.log("user is no valid");
        }
  });
like image 161
Melchia Avatar answered Sep 30 '22 13:09

Melchia