本文整理汇总了TypeScript中angular2-jwt/angular2-jwt.AuthHttp.post方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AuthHttp.post方法的具体用法?TypeScript AuthHttp.post怎么用?TypeScript AuthHttp.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2-jwt/angular2-jwt.AuthHttp
的用法示例。
在下文中一共展示了AuthHttp.post方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: sendAuthHttpRequest
sendAuthHttpRequest(url:string,params?:any,forceGet?:boolean) {
if (forceGet == undefined) {
if (params == undefined) {
forceGet = true;
} else {
forceGet = false;
}
}
if (params == undefined) params = forceGet?'':{};
url = 'http://localhost:5000/api/account/' + url;
if (forceGet) {
if (params.length > 0) url = url + '?' + params
return this._http.get(url)
.map((res: Response) => res.json());
} else {
let body = JSON.stringify(params);
let headers = new Headers({
'Content-Type': 'application/json',
'access-control-allow-origin': '*'
});
let options = new RequestOptions({headers: headers});
return this._http.post(url, body, options)
.map((res: Response) => res.json());
}
}
示例2: saveComment
saveComment(comment:Comment) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
return this.http.post('/comments.json', JSON.stringify(comment), {headers: headers})
.map((res:Response) => res.json());
}
示例3: saveCategory
saveCategory(category:Category) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
if (category.cat_id > 0) {
return this.http.put('/categories/' + category.cat_id + '.json', JSON.stringify(category), {headers: headers})
.map((res:Response) => res.json());
} else {
return this.http.post('/categories.json', JSON.stringify(category), {headers: headers})
.map((res:Response) => res.json());
}
}
示例4: saveArticle
saveArticle(article:Article) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
if (article.art_id > 0) {
return this.http.put('/articles/' + article.art_id + '.json', JSON.stringify(article), {headers: headers})
.map((res:Response) => res.json());
} else {
return this.http.post('/articles.json', JSON.stringify(article), {headers: headers})
.map((res:Response) => res.json());
}
}
示例5: createUser
createUser(user:User):Observable<any> {
let body = {
name: user.name,
email: user.email,
password: user.password
};
return this._http.post('/api/register',JSON.stringify(body))
.map( res => {
return res.json();
})
.catch(err => {
let errMsg = err.message || 'Unkown error';
return Observable.throw(errMsg);
});
}
示例6: saveNew
/**
* Add a new event to the events located at eventsURL
* @param eventsURL
* @param event
* @returns {Observable<Response>}
*/
public saveNew(eventsURL:string, event:EventRequest) {
return this._http.post(eventsURL, JSON.stringify(event));
}
示例7: save
save(app) {
return this._http.post(`${baseUrl}/api/applications`, app, {headers: contentHeaders})
.catch(this.handleException);
}