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