本文整理汇总了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);
}
示例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;
}
示例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);
});
}
示例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);
}
示例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());
}
示例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);
}
示例7: post
post(url, data) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
return this._authHttp.post(url, data, {
headers: headers
});
}
示例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());
});
}
示例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);
}
示例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());
});
}