当前位置: 首页>>代码示例>>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;未经允许,请勿转载。