get请求自定义头信息写法:
getData(url: string, data: any): Observable<any> {
return this.http
.get(this.baseUrl + url, new RequestOptions({
headers: new Headers({
}),
search: data
}))
.map((res: Response) => {
return res.json();
});
}
post请求自定义头信息写法:
login2(data): Observable<any> {
return this.http
.post(this.baseUrl + 'users/login', data,
new RequestOptions({
headers: new Headers({
'Content-Type': 'X-WWW-FORM-URLENCODED',
})
}))
.map((res: Response) => {
return res.json();
});
}
网友评论