I have function that fetches data from api. I need to return the data to a variable declared inside the in class. Below is the the function
getColumns(){
let auth_token='xkjhkdfdfdf';
let url=this.api.apiList.contact_list;
var columns={};
this.common.getRequestTable(url,auth_token).subscribe(
res => {
console.log(res);
columns=res.column_heading;
return columns;
})
}
i have to pass the value to a variable declared in the class
columnList = {}
But when is try like
columnList=this.getColumns();
columnList is undefined