當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript AuthHttp.post方法代碼示例

本文整理匯總了TypeScript中angular2-jwt.AuthHttp.post方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AuthHttp.post方法的具體用法?TypeScript AuthHttp.post怎麽用?TypeScript AuthHttp.post使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2-jwt.AuthHttp的用法示例。


在下文中一共展示了AuthHttp.post方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: addClass

	addClass(scheduleClass: Class) {

		// Convert teacher object to individual form inputs
		let formattedClass: any = scheduleClass;

		formattedClass.teacherPrefix = scheduleClass.teacher.prefix;
		formattedClass.teacherFirstName = scheduleClass.teacher.firstName;
		formattedClass.teacherLastName = scheduleClass.teacher.lastName;
		formattedClass.id = scheduleClass._id;

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

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

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

				return data.id;
			})
			.catch(handleError);
	}
開發者ID:michaelgira23,項目名稱:MyMICDS-v2-Angular,代碼行數:27,代碼來源:classes.service.ts

示例2: getProductById

  getProductById(product_id:number){
    let result:Product;
    let body = JSON.stringify({product_id});        
    this.authHttp.post('http://localhost:3001/productById', body, { headers: contentHeaders })
    .subscribe(
        response => {
          let product_response = response.json().product;            

         
          if(!product_response){
            alert("no hay productos");  
          }
          else{

            result.id = product_response[0].id;
            result.description = product_response[0].description;             

          }
          
          },
          error => {
            alert(error.text());
          });     
      return result;
    }
開發者ID:lanacondio,項目名稱:facu,代碼行數:25,代碼來源:election.ts

示例3: logout

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

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

				// Delete JWT from the client
				sessionStorage.removeItem('id_token');
				localStorage.removeItem('id_token');

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

				return;
			})
			.catch(error => {
				// Remove JWT even if error
				sessionStorage.removeItem('id_token');
				localStorage.removeItem('id_token');

				// Now back to our regularly schedule error handling
				return handleError(error);
			});
	}
開發者ID:michaelgira23,項目名稱:MyMICDS-Mobile,代碼行數:29,代碼來源:auth.ts

示例4: get

	get(date: Date) {
		let body = JSON.stringify(date);
		let headers = xhrHeaders();
		let options = new RequestOptions({ headers });

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

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

				// Convert possible block dates to date objects
				if (data.schedule.classes) {
					for (let i = 0; i < data.schedule.classes.length; i++) {
						if (data.schedule.classes[i].start) {
							data.schedule.classes[i].start = new Date(data.schedule.classes[i].start);
						}
						if (data.schedule.classes[i].end) {
							data.schedule.classes[i].end = new Date(data.schedule.classes[i].end);
						}
					}
				}

				return data.schedule;
			})
			.catch(handleError);
	}
開發者ID:michaelgira23,項目名稱:MyMICDS-v2-Angular,代碼行數:30,代碼來源:schedule.service.ts

示例5: toggleAdmin

	/** Sets the member's admin flag on/off. */
	toggleAdmin(party: Party, member: Member): Observable<boolean> {
		const body = '';
		const options = this.defaultOptions();
		const url = `${API_URL}/${party._key}/${member._key}/toggleAdmin`;
		return this.http.post(url, body, options)
			.map(response => response.json());
	}
開發者ID:andregs,項目名稱:think-before-voting,代碼行數:8,代碼來源:party.service.ts

示例6: getEvents

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

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

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

				// Convert possible event dates to moment.js objects
				if (data.events) {
					for (let i = 0; i < data.events.length; i++) {
						if (data.events[i].start) {
							data.events[i].start = moment(data.events[i].start);
						}
						if (data.events[i].end) {
							data.events[i].end = moment(data.events[i].end);
						}
					}
				}

				return data.events;
			})
			.catch(handleError);
	}
開發者ID:michaelgira23,項目名稱:MyMICDS-v2-Angular,代碼行數:30,代碼來源:planner.service.ts

示例7: post

 post(url, data) {
     let headers = new Headers();
     headers.append('Content-Type', 'application/json');
     return this._authHttp.post(url, data, {
         headers: headers
     });
 }
開發者ID:z424brave,項目名稱:DKClient,代碼行數:7,代碼來源:http-client.ts

示例8: getEvents

  getEvents(){
    
    this.events=[];
    let body = JSON.stringify({});        
    this.authHttp.post('http://localhost:3001/events', body, { headers: contentHeaders })
    .subscribe(
        response => {
          
          let events_response = response.json().events;            
          events_response.forEach((event,index) =>{          
            
              var event_aux: Evt = new Evt();
              event_aux.id = event.id;
              event_aux.start_date = event.start_date;
              event_aux.end_date = event.end_date;
              event_aux.description = event.description;                          
              event_aux.banner_url = event.banner_url;
              this.events.push(event_aux);                          
          });
         
          if(!events_response){
            alert("no hay eventos");  
          }
          
          },
          error => {
            alert(error.text());
          });     

    }
開發者ID:lanacondio,項目名稱:facu,代碼行數:30,代碼來源:events.ts

示例9: dayRotation

	dayRotation() {

		// Check if we already have a cached version of the days
		if (this._days) {
			return Observable.of(this._days);
		}

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

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

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

				this._days = data.days;

				return this._days;
			})
			.catch(handleError);
	}
開發者ID:michaelgira23,項目名稱:MyMICDS-v2-Angular,代碼行數:26,代碼來源:portal.service.ts

示例10: getElections

  getElections(){

    this.election=[];
    let userid = this.user_id;
    let body = JSON.stringify({user_id:userid});

    this.authHttp.post('http://localhost:3001/transactionByUser', body, { headers: contentHeaders })
    .subscribe(
        response => {
          let election_response = response.json().transaction;            
          election_response.forEach((transaction,index) =>{                    
              var transaction_aux: Transaction = new Evt();
              transaction_aux.id = transaction.id;
              transaction_aux.date = transaction.date;
              transaction_aux.id_usr = transaction.usr_id;
              transaction_aux.Product = this.getProductById(transaction.product_id);
              this.election.push(transaction_aux);                          
          });
         
          if(!election_response){
            alert("no hay elecciones");  
          }
          
          },
          error => {
            alert(error.text());
          });     

    }
開發者ID:lanacondio,項目名稱:facu,代碼行數:29,代碼來源:election.ts


注:本文中的angular2-jwt.AuthHttp.post方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。