getProductbyFilter(filter: filterDataModel): Observable<any> {
this.stringtoArrayService.convertStringtoArray(some string input).subscribe(productUserResponse => {
if (productUserResponse) {
this.userProfileProduct = productUserResponse;
this.newParams = this.userProfileProduct[0].Function_Network;
if (this.newParams != null) {
this.updatedStr = this.newParams.replace('&', '__', this.newParams);
} else {
this.updatedStr = this.userProfileProduct[0].Function_Network;
}
}
});
return this.http.post(url + this.updatedStr, filter, httpOptions);}
I have explored various resources which suggest using a method inside subscribe. However, I am encountering an issue where I am unable to access the value of this.updatedStr as it returns undefined. Is there any solution to this problem? Please assist.
assigning variable outside subscribe
how-to-get-value-outside-typescript-subscribe-function