Here is an example to access response body using angular2 built in Response
import { Injectable } from '@angular/core';
import {Http,Response} from '@angular/http';
@Injectable()
export class SampleService {
constructor(private http:Http) { }
getData(){
this.http.get(url)
.map((res:Response) => (
res.json() //Convert response to JSON
//OR
res.text() //Convert response to a string
))
.subscribe(data => {console.log(data)})
}
}
Không có nhận xét nào:
Đăng nhận xét