本文整理汇总了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¶meters=' + 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;未经允许,请勿转载。 |
请发表评论