本文整理匯總了TypeScript中app/http.MyHttp類的典型用法代碼示例。如果您正苦於以下問題:TypeScript MyHttp類的具體用法?TypeScript MyHttp怎麽用?TypeScript MyHttp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了MyHttp類的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: list
list(userId:string, params:{maxId:number, count:number}):Observable<Micropost[]> {
return this.http.get(url(userId), {search: objToSearchParams(params)})
.map(res => res.json())
;
}
示例3: unfollow
unfollow(followerId:string):Observable<Response> {
return this.http.delete(`${url}/to/${followerId}`);
}
示例4: follow
follow(followerId:string):Observable<Response> {
return this.http.post(`${url}/to/${followerId}`, '');
}
示例5: showFeed
showFeed():Observable<Micropost[]> {
return this.http.get(`${url}`)
.map(resp => resp.json())
;
}
示例6: create
create(content:string):Observable<Response> {
const body = JSON.stringify({content: content});
return this.http.post(url, body);
}
示例7: delete
delete(id:Number):Observable<Response> {
return this.http.delete(`${url}/${id}`);
}
示例8: 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())
;
}
示例9: 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'));
});
}
示例10: create
create(params:UserParams):Observable<Response> {
return this.http.post(url, JSON.stringify(params));
}