本文整理匯總了TypeScript中app/http.Http類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Http類的具體用法?TypeScript Http怎麽用?TypeScript Http使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Http類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: login
login(email, password):Observable<Response> {
return this.http.post('/api/login', JSON.stringify({
email: email,
password: password,
})).do(resp => {
localStorage.setItem('jwt', resp.headers.get('X-AUTH-TOKEN'));
});
}
示例2: listFollowers
listFollowers(userId:string, params:{maxId:number, count:number}):Observable<User[]> {
return this.http.get(`${url}/${userId}/followers`, {search: objToSearchParams(params)})
.map(res => res.json())
;
}
示例3: updateMe
updateMe(userParam:UserParams):Observable<Response> {
return this.http.patch(`${url}/me`, JSON.stringify(userParam))
.do(resp => {
localStorage.setItem('jwt', resp.headers.get('X-AUTH-TOKEN'))
});
}
示例4: create
create(params:UserParams):Observable<Response> {
return this.http.post(url, JSON.stringify(params));
}
示例5: get
get(id:string|number):Observable<User> {
return this.http.get(`${url}/${id}`)
.map(res => res.json())
;
}
示例6: list
list(pageRequest:PageRequest = defaultPageRequest):Observable<Page<User>> {
return this.http.get(url, {search: objToSearchParams(pageRequest)})
.map(res => res.json())
;
}
示例7: showFeed
showFeed():Observable<Micropost[]> {
return this.http.get(`${url}`)
.map(resp => resp.json())
;
}
示例8: unfollow
unfollow(followerId:string):Observable<Response> {
return this.http.delete(`${url}/to/${followerId}`);
}
示例9: follow
follow(followerId:string):Observable<Response> {
return this.http.post(`${url}/to/${followerId}`, '');
}
示例10: list
list(userId:string, params:{maxId:number, count:number}):Observable<Micropost[]> {
return this.http.get(url(userId), {search: objToSearchParams(params)})
.map(res => res.json())
;
}