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


TypeScript http.Headers類代碼示例

本文整理匯總了TypeScript中angular2/http.Headers的典型用法代碼示例。如果您正苦於以下問題:TypeScript Headers類的具體用法?TypeScript Headers怎麽用?TypeScript Headers使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: postData

 postData(data){
   let headers = new Headers();
   headers.append('Content-Type', 'application/x-www-form-urlencoded');
   console.log("called get req")
   let httpGetPromise = new Promise((resolve, reject) => {
     console.log("called get req")
     this._http.post('/', data, {headers: headers})
       .map(res => res.json())
       .subscribe(
         data => {
           console.log("data from promise: ", data)
           resolve(data)
         },
         err => reject(err),
         () => console.log('data recieved')
         )
       })
   return httpGetPromise
 }
開發者ID:EnglishMuffinLLC,項目名稱:SearchParty,代碼行數:19,代碼來源:task-service.ts

示例2: onRegister

  onRegister(): void {
	var data = "korisnicko_ime="+this.registerForm.value.korisnicko_ime+"&sifra="+this.registerForm.value.sifra+"&email="+this.registerForm.value.email;
	var headers = new Headers();
	headers.append('Content-Type', 'application/x-www-form-urlencoded');
	this.http.post('http://localhost/it255/php/registracija.php',data, {headers:headers})
    .map(res => res)
    .subscribe( data => this.postResponse = data,
	err => alert(JSON.stringify(err)),
	() => {
	 if(this.postResponse._body == "ok"){
	 alert("Uspesna registracija");
	    this.router.parent.navigate(['./app']);
	 }else{
		alert("Neuspesna registracija");
	 }
	 }
	);

  }
開發者ID:IvanBlagojevic2560,項目名稱:DZ09,代碼行數:19,代碼來源:registracija.component.ts

示例3: login

  login(user: User) {
    var headers = new Headers();
    headers.append("Content-Type", "application/json");

    return this._http.post(
      Config.apiUrl + "oauth/token",
      JSON.stringify({
        username: user.email,
        password: user.password,
        grant_type: "password"
      }),
      { headers: headers }
    )
    .map(response => response.json())
    .do(data => {
      Config.token = data.Result.access_token;
    })
    .catch(this.handleErrors);
  }
開發者ID:devna13,項目名稱:Groceries,代碼行數:19,代碼來源:user.service.ts

示例4: onAddRoom

 onAddRoom(): void {
	var data = "newRoomName="+this.signupForm.value.newRoomName+"&tv="+this.signupForm.value.tv+"&beds="+this.signupForm.value.beds+"&kvadratura="+this.signupForm.value.kvadratura;
	var headers = new Headers();
	headers.append('Content-Type', 'application/x-www-form-urlencoded');
	this.http.post('http://localhost/php/addroom.php',data, {headers:headers})
    .map(res => res)
    .subscribe( data => this.postResponse = data,
	err => alert(JSON.stringify(err)),
	() => { 
	 if(this.postResponse._body.indexOf("error") === -1){
		alert("Uspesno dodavanje sobe");
	    this.router.parent.navigate(['./Home']);
	 }else{
		alert("Neuspesno dodavanje sobe");
	 }
	 }
	);
	
  }
開發者ID:jovanastricic2413,項目名稱:IT255-DZ12,代碼行數:19,代碼來源:addroom.component.ts

示例5: signin

 signin(username:string, password:string) {      
     var creds = "username=" + username + "&password=" + password;
     
     var headers = new Headers();
     headers.append('Content-Type', 'application/x-www-form-urlencoded');
 
     this.http.post('http://localhost:8080/account/token', creds, {
         headers: headers
     })
     .map(res => res.json())
     .subscribe(
         data => { 
             this.saveJwt(data.access_token);
             this._router.navigate(['Dashboard']);
         },
         err => console.error(err),
         () => console.log('Authentication Complete')
     );
 }
開發者ID:benripley,項目名稱:TakingStock-ng2,代碼行數:19,代碼來源:auth.service.ts

示例6: sendNotification

    public sendNotification(RestaurantEmail:string, TableNr:string) {


        let parameters = JSON.stringify({
            restaurant: RestaurantEmail,
            tableNr: TableNr
        });


        let header:Headers = new Headers();

        header.append('Content-Type', 'application/json');
        header.append('AnonymousToken', ConfigBackand.anonymous_token);

        return this.http.get(ConfigBackand.api_url + '1/objects/action/Order/?name=SendRealtimeEvent&parameters=' + encodeURI(parameters), {headers: header})
            .map(res => res.json())


    }
開發者ID:ionutleustean,項目名稱:MyWaiter,代碼行數:19,代碼來源:Order.ts

示例7: getTables

    public getTables(restaurantId) {

        if (restaurantId != null || restaurantId != "") {
            let filter = JSON.stringify([{"fieldName": "RestaurantId", "operator": "equals", "value": restaurantId}]);

            let header:Headers = new Headers();

            header.append('AnonymousToken', ConfigBackand.anonymous_token);

            return this.http.get(ConfigBackand.api_url + '1/objects/Tables?filter=' + encodeURI(filter), {
                headers: header
            })
                .retry(3)
                .map(res => res.json().data.map(r => r))
        }
        else {

        }
    }
開發者ID:ionutleustean,項目名稱:MyWaiter,代碼行數:19,代碼來源:Order.ts

示例8: Courses_GetCourses

	/**
  *
	* @method
	* @name Courses_GetCourses
	* @param {string} q - 
	* 
	*/
	public Courses_GetCourses(q: string) {
		let payload = {};	
		let queryParameters = new URLSearchParams();
		let headers = new Headers();
		headers.append('Content-Type', 'application/json');
		
      
		if(q !== undefined){
			queryParameters.set('q', q);
		}
			
		let uri = `/api/courses`;
	  
		return this.http
			.get(this.domain + uri, { headers: headers, search: queryParameters })
			.map((res: Response) => {
        return res;
      });
	}
開發者ID:maxamillion32,項目名稱:fitness-ionic,代碼行數:26,代碼來源:index.ts

示例9: save

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

        var _this = this;
        this.loading = true;
        var json = JSON.stringify(this.catToEdit);
        console.log(json);
        _this._http.post('/api/Category', json,
            { headers: headers }).map(r => r.json()).subscribe(x => {
                _this.loading = true;
                _this.load();
            },
            error => {
                _this._errorHandler.handleError(error);
                _this.loading = false;
            });

    }
開發者ID:daviddcbud,項目名稱:MySongs,代碼行數:19,代碼來源:categoryComponent.ts

示例10: login

 public login(user: User): Observable<Response>{
     var headers = new Headers();
     headers.append('Content-Type', 'application/json');
     
     return this._http.post(
         Config.apiUrl + 'oauth/token',
         JSON.stringify({
             username: user.email,
             password: user.password,
             grant_type: 'password'
         }),
         { headers: headers }
     )
     .map(response => response.json())
     .do(data => {
         Config.token = data.Result.access_token;
     })
     .catch(this.handleErrors);
 }
開發者ID:phcbarros,項目名稱:NativeScript,代碼行數:19,代碼來源:user.service.ts


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