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


TypeScript Http.post方法代码示例

本文整理汇总了TypeScript中angular2/http.Http.post方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Http.post方法的具体用法?TypeScript Http.post怎么用?TypeScript Http.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/http.Http的用法示例。


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

示例1: post

    post(request) {
        //console.log(request)

        let body = JSON.stringify(request.data);
        
        let headers = this.buildHeaders([
            { key: 'Content-Type', value: 'application/json' },
            { key: 'Accept', value: 'application/json' }
        ]);

        let options = new RequestOptions({ headers: headers });

        return this.http.post(request.url, body, options);
    }
开发者ID:bram-atmire,项目名称:angular2-ui-prototype,代码行数:14,代码来源:http.service.ts

示例2: addRole

 addRole(role) {
     var headers = new Headers();
     headers.append('Content-Type', 'application/json');
     return this._http.post(this._config.apiEndpoint + '/role', JSON.stringify(role), { // All hosts to config.
         headers: new Headers({
             'Authorization': 'Bearer ' + this._auth.getToken(),
             'Content-Type': 'application/json'
         })
     }).map((res) => {
         let doc = res.json();
         let roles = doc;
         return roles;
     });
 }
开发者ID:RickHocutt,项目名称:MEAN-SaaS-Api-Starter,代码行数:14,代码来源:role.service.ts

示例3: Headers

 .flatMap( (saga)=>{
     console.log('init post ',saga);
     var t=localStorage.getItem('token'); 
     if (t==null) return Observable.of(null);
     var h:Headers=new Headers();
     h.append('Authorization',t);
     
     const query=http.post('http://virtual2.ballistix.co.uk:8000/api/maintenance',JSON.stringify({type:''}),{headers:h});
 
       
 
     return query.map((e)=>e.json()).catch((e)=>{return Observable.of(null)});
    
 })
开发者ID:JamesUlph,项目名称:ng2-start,代码行数:14,代码来源:sagas.ts

示例4: putAlumno

    // PUT
    public putAlumno(alumno: Alumno) {

        var obj = {
            '__metadata': { 'type': 'SP.Data.AlumnoListItem' },
            'Nombre': alumno.nombre,
            'Apellidos': alumno.apellidos,
            'Puntuacion': alumno.puntuacion,
            'Guid': alumno.userGuid,
            'AccountName': alumno.accountName
        };

        var data = JSON.stringify(obj);
        return this.http.post(this.spApiUrl + "/_api/web/lists/getByTitle('Alumno')/items(" + alumno.id + ")", data, { headers: this.setHeaders("PUT") });
    }
开发者ID:FranLsz,项目名称:SharePoint-SeleccionEmpresas-Proyecto,代码行数:15,代码来源:alumno.service.ts

示例5: return

 let result = Observable.create((observable) => {
   this._http.post(this.getSaveEndpoint(obj.id), JSON.stringify(obj))
       .map(res => res.json())
       .map((instance: any) => {
         if (instance) {
           return (this.fromJson(instance));
         }
         return null;
       }).subscribe(
         (data) => observable.next(data),
         (err) => observable.error(err),
         () => observable.complete()
       );
  });
开发者ID:xetus-oss,项目名称:pciwake-web,代码行数:14,代码来源:crud.service.ts

示例6: addPerson

    addPerson(name: string) {
        var data = {
            Name: name
        };

        var headers = new Headers();
        headers.append('Content-Type', 'application/json');

        return this._http.post(
            'http://localhost:51523/api/home',
            JSON.stringify(data), {
                headers: headers
            });
    }
开发者ID:VladimirDimov,项目名称:Learning,代码行数:14,代码来源:app.service.ts

示例7: login

    login (username: string, password: string, profile: number): Observable<string>  {

        var loginData = [username, password, profile];
        let body = JSON.stringify(loginData);
        //let body = [username, password, profile];
        console.log("RequestBody = " + body);
        let headers = new Headers({ 'Content-Type': 'application/json' });
        let options = new RequestOptions({ headers: headers });

        return this.http.post(BackEndURL + '/login', body, options)
                        .map(this.extractData)
                        .catch(this.handleError);

    }
开发者ID:IndomitoGallo,项目名称:GestioneProgetti,代码行数:14,代码来源:login.service.ts

示例8: Promise

		return new Promise(resolve => {
			this.http.post(url, datatobepost, {
				headers: headers
			})
				.map(res => res.json())
				.subscribe(
				data => {
					resolve(data);
				},
				err => {
					resolve('Error');
				}
				);
		});
开发者ID:manishks12288,项目名称:unite-framework,代码行数:14,代码来源:uniteitem.ts

示例9: addJSON

	addJSON(url: string, obj: any, cb: ServerResponse): void {

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

		let options: RequestOptions = new RequestOptions();
		options.headers = headers;

		this.http.post(url, JSON.stringify(obj), options)
			.subscribe((res: Response) => {
				cb(res.json());		//callBack		
            });	//http.post
        
	} 	//addJSON
开发者ID:Muhammad-MuZzammil,项目名称:Ionic2-Projects,代码行数:14,代码来源:httpService.ts

示例10: anadirJugador

 anadirJugador(nombre:string, posicion:string, kda:number, equipo:number){
   let url = "https://localhost:8443/jugadores/";
   let item = { "nombre":nombre, "posicion":posicion, "media":kda, "equipo":{"id": equipo}
 };
 let body = JSON.stringify(item);
 let headers = new Headers({
   'Content-Type': 'application/json'
 });
 let options = new RequestOptions({ headers });
 return this.http.post(url, body, options)
     .map(response => response.json())
     .catch(error => this.manejarError(error)
   );
 }
开发者ID:igomezal,项目名称:eSportiumV2,代码行数:14,代码来源:jugador.interface.ts


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