How to return response of webservice through function


#1

i want to return response as string and i got response as string but problem is that post method is not call and direct return null value.

Code that i used

getLoginDetails(username,password) : string{
var sRequest1 = ‘LOGIN’+ username +’’+ password +’’;

let headers = new Headers();
headers.append('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');

 this.http.post(`${this.link}/DoLogin`,'sRequest=' + sRequest1,{ headers: headers }).map(res => res.text()).subscribe(
          data => {
          this.resString = data;
          this.resString = this.resString.substring(this.resString.indexOf("{"), this.resString.indexOf("}") + 2);
          return this.resString;
        },
          err => console.error(err),
          () => console.log(this.resString) );

Direct this return ----> return this.resString;
}