當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。