updatePassenger(passenger: Passenger): Observable<Passenger> { let headers = new Headers({ 'Content-Type': 'application/json' }); let options = new RequestOptions({ headers: headers }); return this.http .put(`${PASSENGER_API}/${passenger.id}`, passenger, options) .map((response: Response) => response.json()); }
From Angular V4, there is new HttpClient module, in which HttpHeaders is an immutable api.
const headers = new HttpHeaders() .set("X-CustomHeader", "custom header value"); this.courses$ = this.http .get( "/courses.json", {headers}) .do(console.log) .map(data => _.values(data));
最后
以上就是俊秀豌豆最近收集整理的关于[Angular] Http Custom Headers and RequestOptions的全部内容,更多相关[Angular]内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复