I've tried to get value out from subscribe of boolean true/false but i can't get value out, here is what i used so far.
My Old method for http post.
this.http.post(HostedPathConst.HostedPath + `CompanyProfile/UpdateCustomersStatus`, fData)
.subscribe(data => this.Success(data), err => this.Error(err));
this.Success(data)
and this.Error(err)
are methods being called now, the new way i tried to get data out is this.
const fData = new FormData();
fData.append('Id', Id.toString());
fData.append('IsActive', IsActive.toString());
const test = this.http.post(HostedPathConst.HostedPath + `CompanyProfile/UpdateCustomersStatus`, fData)
.subscribe(data => {
this.Success(data);
this.Switch = IsActive;
return this.Switch;
},
err => {
this.Error(err);
this.Switch = !IsActive;
return this.Switch;
});
console.log(test);//Subscriber {closed: false, _parentOrParents: null, _subscriptions: Array(1), syncErrorValue: null, syncErrorThrown: false, …}
console.log(this.Switch);//undefined at first then gives opposite result like true gives false and vice versa
As this.Switch = IsActive;
the boolean value to get data out it returns undefined at first then after wards it returns value false instead of true and vice versa.