如何从http.post(Angular2)调用的PHP文件中捕获回显值?

如何从http.post(Angular2)调用的PHP文件中捕获回显值?

问题描述:

I'm calling a PHP file with the following code:

var link = 'link.php';

var data = JSON.stringify({ email: this.data.email, password: this.data.password});

let headers = new Headers();
headers.append('Content-Type', 'application/json');

this.http.post(link, data, { headers: headers }).subscribe(res => {
  alert(res);
});

I'm echoing a string from the PHP file, but nothing is being stored in res. Is there something I'm missing, or am I completely going about it the wrong way?

Thanks

Solved it. Needed to use

res.text()