当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript AuthHttp.get方法代码示例

本文整理汇总了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()
       );
   }
 }
开发者ID:Antyneskul,项目名称:angular2-authentication-sample,代码行数:19,代码来源:home.ts

示例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;
       }
     );
   }
 }
开发者ID:zoroloco,项目名称:druidia,代码行数:26,代码来源:auth.service.ts

示例3: getOneService

 getOneService(serviceId: string): Observable<any> {
     return this.authHttp.get(`/api/service/getOneService/${serviceId}`)
         .map(this.handelResponse)
         .catch(this.handelError)
 }
开发者ID:amazingandyyy,项目名称:yeah-ng2,代码行数:5,代码来源:service.service.ts

示例4: register

 register():Observable<User> {
     return this.authHttp.get(USER_URL + "register")
         .map((res) => res.json() || {})
         .catch(this.handleError);
 }
开发者ID:travisolbrich,项目名称:scavenger-hunt-ui,代码行数:5,代码来源:user.service.ts

示例5: getOrders

 getOrders (): Observable<OrderModel[]> {
   return this.authHttp.get(`${environment.baseUrl}/order/api/`)
                   .map(this.extractData)
                   .catch(this.handleError);
 }
开发者ID:rj76,项目名称:angular2-client,代码行数:5,代码来源:order.service.ts

示例6: getOrdersById

 getOrdersById(): Observable<any> {
   const ordersUrl = `/api/user/orders`; // api url
   return this.authHttp
     .get(ordersUrl)
     .pipe(map((res: Response) => res.json()));
 }
开发者ID:sumanbh,项目名称:amazon-clone,代码行数:6,代码来源:orders.service.ts

示例7: getDate

 public getDate (): Observable<any> {
   return this.http.get('http://localhost:8000/api/Test/getuserinfo');
 }
开发者ID:Liteolika,项目名称:ASOSDemo,代码行数:3,代码来源:backend.service.ts

示例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());
 }
开发者ID:urbanlink,项目名称:vooot-api,代码行数:6,代码来源:vooot-person.service.ts

示例9: getCompanies

 getCompanies():Promise<Company[]> {
     return this.http.get(this.conf.companiesURL())
         .toPromise()
         .then(response => response.json());
 }
开发者ID:rudkodm,项目名称:closer-ui,代码行数:5,代码来源:companies.service.ts

示例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));
 }
开发者ID:empirefox,项目名称:ec-front,代码行数:6,代码来源:retry-http.ts


注:本文中的angular2-jwt.AuthHttp.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。