本文整理汇总了TypeScript中angular2-jwt.AuthHttp.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AuthHttp.get方法的具体用法?TypeScript AuthHttp.get怎么用?TypeScript AuthHttp.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2-jwt.AuthHttp
的用法示例。
在下文中一共展示了AuthHttp.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _callApi
_callApi(type, url) {
this.response = null;
if (type === 'Anonymous') {
// For non-protected routes, just use Http
this.http.get(url)
.subscribe(
response => this.response = response.text(),
error => this.response = error.text()
);
}
if (type === 'Secured') {
// For protected routes, use AuthHttp
this.authHttp.get(url)
.subscribe(
response => this.response = response.text(),
error => this.response = error.text()
);
}
}
示例2: fetchUser
//observe fetching user either from the localstorage or the back-end.
//anyone subscribing to this observable will only fetch from back-end the first time.
public fetchUser(): Observable<User>{
if(!_.isEmpty(localStorage.getItem('user'))){
this.log.log("Returning observable for local storage user.");
return Observable.of(localStorage.getItem('user'))
.map((userStr:string) => {
this.log.log("Returning local storage saved user.");
let resultUser:BaseUser = JSON.parse(userStr);
return this.userFactory.createUser(resultUser);
});
}
else{//fetch from back-end api.
this.log.log("Returning observable for api call fetch user.");
return this.authHttp.get(`api/fetchUser`)
.map((res:Response) => {
//store away for next time
let resultUser:BaseUser = res.json();
let user:User = this.userFactory.createUser(resultUser);
this.log.log("Returning api fetched user.");
localStorage.setItem('user',JSON.stringify(user));
return user;
}
);
}
}
示例3: getOneService
getOneService(serviceId: string): Observable<any> {
return this.authHttp.get(`/api/service/getOneService/${serviceId}`)
.map(this.handelResponse)
.catch(this.handelError)
}
示例4: register
register():Observable<User> {
return this.authHttp.get(USER_URL + "register")
.map((res) => res.json() || {})
.catch(this.handleError);
}
示例5: getOrders
getOrders (): Observable<OrderModel[]> {
return this.authHttp.get(`${environment.baseUrl}/order/api/`)
.map(this.extractData)
.catch(this.handleError);
}
示例6: getOrdersById
getOrdersById(): Observable<any> {
const ordersUrl = `/api/user/orders`; // api url
return this.authHttp
.get(ordersUrl)
.pipe(map((res: Response) => res.json()));
}
示例7: getDate
public getDate (): Observable<any> {
return this.http.get('http://localhost:8000/api/Test/getuserinfo');
}
示例8: search
public search(term:any):Observable<any> {
console.log(term);
return this.http.get(
env.apiRoot + '/person/query?term=' + term
).map(res=>res.json());
}
示例9: getCompanies
getCompanies():Promise<Company[]> {
return this.http.get(this.conf.companiesURL())
.toPromise()
.then(response => response.json());
}
示例10: get
public get(url: string, options?: RequestOptionsArgs): Observable<Response> {
return this.http.get(url, options).catch((error) =>
error.status === 401 ?
this.tokenService.mustUpdateToken().flatMap((data: any) => this.get(url, options)) :
Observable.throw(error));
}