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


TypeScript angular2-jwt.AuthHttp类代码示例

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


在下文中一共展示了AuthHttp类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:Bort-777,项目名称:angular2-authentication-sample,代码行数:19,代码来源:home.ts

示例2: Error

	addEvent(event: any) {
		let body = JSON.stringify(event);
		let headers = xhrHeaders();
		let options = new RequestOptions({ headers });

		return this.authHttp.post(environment.backendURL + '/planner/add', body, options)
			.map(res => {
				let data = res.json();

				// Check if server-side error
				if (data.error) {
					throw new Error(data.error);
				}

				return data.events;
			})
			.catch(handleError);
	}
开发者ID:michaelgira23,项目名称:MyMICDS-v2-Angular,代码行数:18,代码来源:planner.service.ts

示例3: Error

	post(moduleId: string, text: string) {
		let body = JSON.stringify({ moduleId, text });
		let headers = xhrHeaders();
		let options = new RequestOptions({ headers });

		return this.authHttp.post(environment.backendURL + '/stickynotes/post', body, options)
			.map(res => {
				let data = res.json();

				// Check if server-side error
				if (data.error) {
					throw new Error(data.error);
				}

				return data.success;
			})
			.catch(handleError);
	}
开发者ID:michaelgira23,项目名称:MyMICDS-v2-Angular,代码行数:18,代码来源:stickynotes.service.ts

示例4: Error

	upsert(modules: Module[]): Observable<Module[]> {
		let body = JSON.stringify({ modules });
		let headers = xhrHeaders();
		let options = new RequestOptions({ headers });

		return this.authHttp.post(environment.backendURL + '/modules/upsert', body, options)
			.map(res => {
				let data = res.json();

				// Check if server-side error
				if (data.error) {
					throw new Error(data.error);
				}

				return data.modules;
			})
			.catch(handleError);
	}
开发者ID:michaelgira23,项目名称:MyMICDS-v2-Angular,代码行数:18,代码来源:modules.service.ts

示例5: Error

	deleteClass(id: string) {
		let body = JSON.stringify({ id });
		let headers = xhrHeaders();
		let options = new RequestOptions({ headers });

		return this.authHttp.post(environment.backendURL + '/classes/delete', body, options)
			.map(res => {
				let data = res.json();

				// Check if server-side error
				if (data.error) {
					throw new Error(data.error);
				}

				return;
			})
			.catch(handleError);
	}
开发者ID:michaelgira23,项目名称:MyMICDS-v2-Angular,代码行数:18,代码来源:classes.service.ts

示例6: Error

	getScores() {
		let body = JSON.stringify({});
		let headers = xhrHeaders();
		let options = new RequestOptions({ headers });

		return this.authHttp.post(environment.backendURL + '/user/get-info', body, options)
			.map( res => {
				let data = res.json();

				// Check if server-side error
				if (data.error) {
					throw new Error(data.error);
				}

				return data.user;
			})
			.catch(handleError);
	}
开发者ID:michaelgira23,项目名称:MyMICDS-Mobile,代码行数:18,代码来源:sports.ts

示例7: Error

	getClasses() {
		let body = JSON.stringify({});
		let headers = xhrHeaders();
		let options = new RequestOptions({ headers });

		return this.authHttp.post(environment.backendURL + '/canvas/get-classes', body, options)
			.map(res => {
				let data = res.json();

				// Check if server-side error
				if (data.error) {
					throw new Error(data.error);
				}

				return {
					hasURL: data.hasURL,
					classes: data.classes
				};
			})
			.catch(handleError);
	}
开发者ID:michaelgira23,项目名称:MyMICDS-v2-Angular,代码行数:21,代码来源:canvas.service.ts

示例8: Promise

        return new Promise((resolve, reject) => {

            if (!this.getToken()) {
                this.http.post(
                    API.URL + 'oauth/access_token',
                    API.MERGE_PARAMS(credentials)
                ).subscribe(
                        data => {
                        let response = data.json();
                        localStorage.setItem('access_token', response['access_token']);
                        resolve(response);
                    },
                        err => {
                        console.log(err);
                        reject(err);
                    },
                    () => console.log('finish request')
                );
            } else {
                resolve();
            }

        });
开发者ID:brunogonncalves,项目名称:ng2-admin,代码行数:23,代码来源:auth.service.ts


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