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