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


TypeScript angular2-jwt.AuthHttp类代码示例

本文整理汇总了TypeScript中angular2-jwt/angular2-jwt.AuthHttp的典型用法代码示例。如果您正苦于以下问题:TypeScript AuthHttp类的具体用法?TypeScript AuthHttp怎么用?TypeScript AuthHttp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AuthHttp类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: sendAuthHttpRequest

 sendAuthHttpRequest(url:string,params?:any,forceGet?:boolean) {
     if (forceGet == undefined) {
         if (params == undefined) {
             forceGet = true;
         } else {
             forceGet = false;
         }
     }
     if (params == undefined) params = forceGet?'':{};
     url = 'http://localhost:5000/api/account/' + url;
     if (forceGet) {
         if (params.length > 0) url = url + '?' + params
         return this._http.get(url)
             .map((res: Response) => res.json());
     } else {
         let body = JSON.stringify(params);
         let headers = new Headers({
             'Content-Type': 'application/json',
             'access-control-allow-origin': '*'
         });
         let options = new RequestOptions({headers: headers});
         return this._http.post(url, body, options)
             .map((res: Response) => res.json());
     }
 }
开发者ID:alkovpro,项目名称:times,代码行数:25,代码来源:profile.service.ts

示例2: saveArticle

    saveArticle(article:Article) {
        let headers = new Headers();
        headers.append('Content-Type', 'application/json');

        if (article.art_id > 0) {
            return this.http.put('/articles/' + article.art_id + '.json', JSON.stringify(article), {headers: headers})
                .map((res:Response) => res.json());
        } else {
            return this.http.post('/articles.json', JSON.stringify(article), {headers: headers})
                .map((res:Response) => res.json());
        }
    }
开发者ID:DawidKre,项目名称:szkolenie_mvc,代码行数:12,代码来源:articles.service.ts

示例3: saveCategory

    saveCategory(category:Category) {
        let headers = new Headers();
        headers.append('Content-Type', 'application/json');

        if (category.cat_id > 0) {
            return this.http.put('/categories/' + category.cat_id + '.json', JSON.stringify(category), {headers: headers})
                .map((res:Response) => res.json());
        } else {
            return this.http.post('/categories.json', JSON.stringify(category), {headers: headers})
                .map((res:Response) => res.json());
        }
    }
开发者ID:DawidKre,项目名称:szkolenie_mvc,代码行数:12,代码来源:categories.service.ts

示例4:

            this._userService.getUser('http://localhost:8080/api/accounts/' + userId).subscribe(user => {

                currUser = user;
                this._http.get(url_frequency, options)
                    .map(res => {
                        let result = res.json();
                        return result.frequency;
                    })
                    .catch(err => {
                        let errMsg = err.message || 'Unkown error';
                        return Observable.throw(errMsg);
                    })
                    .subscribe(
                        result => {
                            frequency = result;


                            observer.next({
                                name: 'temperature_optimization',
                                url: 'http://klimaoptimierungsservice.eu-gb.mybluemix.net/api/temperature_optimization',
                                frequency: frequency,
                                mostActiveUser: currUser
                            });
                        }
                    );

            });
开发者ID:mducnguyen,项目名称:KlimaoptimierungSimulator,代码行数:27,代码来源:api-user-usage.ts

示例5:

                    result => {
                        frequency = result;
                        this._http.get(url_usage, options)
                            .flatMap(res => {
                                let result = res.json();
                                if (isArray(result)) {
                                    return this.getMostActiveUser(result);
                                } else {
                                    throw new Error;
                                }
                            })
                            .catch(err => {
                                let errMsg = err.message || 'Unkown error';
                                return Observable.throw(errMsg);
                            })
                            .subscribe(
                                user => {
                                    mostActiveUser = user;

                                    observer.next({
                                        name: 'temperature_optimization',
                                        url: 'http://klimaoptimierungsservice.eu-gb.mybluemix.net/api/temperature_optimization',
                                        frequency: frequency,
                                        mostActiveUser: mostActiveUser
                                    });
                                }
                            );
                    }
开发者ID:mducnguyen,项目名称:KlimaoptimierungSimulator,代码行数:28,代码来源:api-ranking.service.ts

示例6: saveComment

    saveComment(comment:Comment) {
        let headers = new Headers();
        headers.append('Content-Type', 'application/json');

        return this.http.post('/comments.json', JSON.stringify(comment), {headers: headers})
            .map((res:Response) => res.json());

    }
开发者ID:DawidKre,项目名称:szkolenie_mvc,代码行数:8,代码来源:articles.service.ts

示例7: getEvents

 /**
  * Get a list of events located at eventsURL
  * @param eventsURL
  * @returns {Observable<R>}
  */
 public getEvents(eventsURL:string):Observable<Event[]> {
     return this._http.get(eventsURL).map(res => {
         let body = res.json();
         return body.items.map((eventJSON) => {
             return new Event(eventJSON);
         });
     });
 }
开发者ID:mducnguyen,项目名称:TicklrClient,代码行数:13,代码来源:event.service.ts

示例8: Headers

        return new Observable<Api>((observer:Observer<Api>) => {

            let options = {
                headers: new Headers({'Content-Type': 'application/json'})
            };

            // let url_frequency = 'http://localhost:8080/api/tracking/temperature_optimization/occurence';
            // let url_usage = 'http://localhost:8080/api/tracking/temperature_optimization';

            let frequency = 0;
            let mostActiveUser:User;

            this._http.get(url_frequency, options)
                .map(res => {
                    let result = res.json();
                    return result.frequency;
                })
                .catch(err => {
                    let errMsg = err.message || 'Unkown error';
                    return Observable.throw(errMsg);
                })
                .subscribe(
                    result => {
                        frequency = result;
                        this._http.get(url_usage, options)
                            .flatMap(res => {
                                let result = res.json();
                                if (isArray(result)) {
                                    return this.getMostActiveUser(result);
                                } else {
                                    throw new Error;
                                }
                            })
                            .catch(err => {
                                let errMsg = err.message || 'Unkown error';
                                return Observable.throw(errMsg);
                            })
                            .subscribe(
                                user => {
                                    mostActiveUser = user;

                                    observer.next({
                                        name: 'temperature_optimization',
                                        url: 'http://klimaoptimierungsservice.eu-gb.mybluemix.net/api/temperature_optimization',
                                        frequency: frequency,
                                        mostActiveUser: mostActiveUser
                                    });
                                }
                            );
                    }
                );
        });
开发者ID:mducnguyen,项目名称:KlimaoptimierungSimulator,代码行数:52,代码来源:api-ranking.service.ts

示例9: adminUpdateEmail

 adminUpdateEmail(user: User): Observable<any> {
     var body = {
         name : user.name,
         email : user.email
     };
     return this._http.put('/api/admin/users/'+ user.name+'/email', JSON.stringify(body))
         .map( res => {
             return res.json();
         })
         .catch(err => {
             let errMsg = err.message || 'Unkown error';
             return Observable.throw(errMsg);
         });
 }
开发者ID:mducnguyen,项目名称:AccountAdmin,代码行数:14,代码来源:user.service.ts

示例10: User

    /**
     * Fetches a user resource located at url
     * @param url URL to the user resource
     * @return
     */
    getUser(url:string):Observable<User> {

        return this._http.get(url)
            .map(res => {
                if (200 == res.status) {
                    return new User(res.json());
                } else if (401 == res.status) {
                    throw new Error("Authorization failed: current user is not allowed to access this resource.");
                } else {
                    throw new Error("Unknown error");
                }
            }).catch(err => {
                let errMsg = err.message || 'Unknown error';
                return Observable.throw(errMsg);
            });
    }
开发者ID:mducnguyen,项目名称:TicklrClient,代码行数:21,代码来源:user.service.ts


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