本文整理汇总了TypeScript中@angular/http.URLSearchParams.set方法的典型用法代码示例。如果您正苦于以下问题:TypeScript URLSearchParams.set方法的具体用法?TypeScript URLSearchParams.set怎么用?TypeScript URLSearchParams.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/http.URLSearchParams
的用法示例。
在下文中一共展示了URLSearchParams.set方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: resetPassword
resetPassword(uuid: string, newPassword: string): Promise<any> {
if (!uuid || !newPassword) {
return Promise.reject("Invalid reset uuid or password");
}
let body: URLSearchParams = new URLSearchParams();
body.set("reset_uuid", uuid);
body.set("password", newPassword);
return this.http.post(resetPasswordEndpoint, body.toString(), HTTP_FORM_OPTIONS)
.toPromise()
.then(response => response)
.catch(error => {
return Promise.reject(error);
});
}
示例2: initCollection
private initCollection(params){
this.searchParams = params['collection_id'];
let getParams = new URLSearchParams();
getParams.set('populate', '_author+_thumbnail');
this.isLoadingCollection = true;
this.collectionService.getCollection(this.searchParams, getParams).subscribe((collection) => {
this.collection = collection;
this.titleService.setTitle(this.collection.title + ' | TidyCards');
this.collection._items = [];
if(this.authService.isLoggedIn && collection._author._id === this.authService.currentUser._id)
this.isAuthor = true;
this.isLoadingCollection = false;
setTimeout( () => {
$("#collectionDetailHeader").removeClass('is-hidden');
}, 10);
this.emitUpdateHeaderEvent();
this.loadItems();
}, (error) => {
var errorBody = JSON.parse(error._body);
var star = null
if(errorBody.data)
star = errorBody.data._star;
if(star){
this.collection = new TcCollection();
this.collection._star = TcStar.createFormJson(star);
this.cantFoundButwasStarred = true;
}
this.isLoadingCollection = false;
});
}
示例3: fetchSurvey
fetchSurvey(id?: number): Observable<{}> {
let headers: Headers = new Headers({ 'Content-Type': 'application/json' });
let options: any = { headers: headers };
let ReqOptions: RequestOptions;
let search = new URLSearchParams();
if (id) {
search.set('id', '' + id);
options.search = search;
}
ReqOptions = new RequestOptions(options);
return this.http.get('/api/survey', ReqOptions)
.map((res: Response) => res.json())
.map(res => {
this.surveyData = {
total: res.survey.total,
title: res.survey.title,
id: res.survey.id,
options: res.options
};
this._surveyChangeObs.next(this.surveyData);
return res;
});
}
示例4: getUsers
//Get list of existing users
getUsers(limit: Number): Observable<User[]>{
//Setup url parameters
let params = new URLSearchParams();
params.set("limit", limit.toString());
//Make http get request
var request = this.http.request(new Request(new RequestOptions({
method: RequestMethod.Get,
url: "/api/v1/users",
search: params
})));
//Parse json response and map to object
return request
.map(res => res.json())
.map(res => {
//Check response for errors
if (res.hasOwnProperty('error')){
alert(res.error);
throw new Error(res.error);
}else{
return res.users;
}
})
.map(res => res.map(u => new User(u.userId, u.username, u.email)));
}
示例5: deleteUser
//Delete user from backend with identifier
deleteUser(userId: string){
//Setup url parameters
let params = new URLSearchParams();
params.set("userId", userId);
//Make http delete request
var request = this.http.request(new Request(new RequestOptions({
method: RequestMethod.Delete,
url: "/api/v1/users",
search: params
})));
//Parse json response
return request
.map(res => res.json())
.map(res => {
//Check response for errors
if (res.hasOwnProperty('error')){
throw new Error(res.error);
}else{
return res;
}
});
}
示例6: findByUser
/**
*
* @param userId
* @returns {Observable<any[]>}
*/
public findByUser(userId: number): Observable<Course[]>
{
let params = new URLSearchParams();
params.set('user', userId.toString());
return this.httpService.search(AppConstants.COURSES_URL + "/search/findByUser", params);
}
示例7: getTTSAccessToken
// 百度TTS 合成token
getTTSAccessToken()
{
let url = "https://openapi.baidu.com/oauth/2.0/token";
let params = {
"grant_type": "client_credentials",
"client_id": "TPnGgO8zxIayL9iTTctlxqny",
"client_secret": "820591dad6912546574487991d6bcb7d"
};
if(this.platform.is("cordova"))
{
return Observable.fromPromise(this.nativeHttp.get(url, params, {})).map((res:any) =>{
return JSON.parse(res.data);
}).catch(this.handleError);
}
else
{
url = url.replace("https:/", "");
let searchParams = new URLSearchParams();
for(let key in params)
{
searchParams.set(key, params[key]);
}
let reqOpts = new RequestOptions({"search": searchParams, "headers": new Headers()});
return this.http.get(url, reqOpts).map(res=>{
return res.json();
}).catch(this.handleError);
}
}
示例8: getCourses
/**
* @returns {Observable<any[]>}
*/
getCourses(userId: number): Observable<Course[]>
{
let params = new URLSearchParams();
params.set('userId', userId.toString());
return this.httpService.search(AppConstants.COURSES_URL, params);
}
示例9: getGeoEntitySuggestions
getGeoEntitySuggestions(parentId: string, universalId: string, text: string, limit: string): Promise<Array<{ text: string, data: any }>> {
let params: URLSearchParams = new URLSearchParams();
params.set('parentId', parentId);
params.set('universalId', universalId);
params.set('text', text);
params.set('limit', limit);
return this.http
.get(acp + '/uploader/getGeoEntitySuggestions', {search: params})
.toPromise()
.then((response: any) => {
return response.json() as Array<{ text: string, data: any }>;
})
.catch(this.handleError.bind(this));
}
示例10: getTaxiSaftyInfosByDriverNo
/**
* Get the safity infomation
* driverNo:
*/
public getTaxiSaftyInfosByDriverNo(driverNo: string): Observable<SaftyInfoBean[]> {
let headers = new Headers({ 'Content-Type': HEADER_CONTENT_TYPE });
let searchs = new URLSearchParams();
searchs.set("driverNo", driverNo);
searchs.set("accountCode", this.commonHttpService.accountInfo.accountCode);
let options = new RequestOptions({ headers: headers, search: searchs });
return this.http.get(API_BASEURL + "getTaxiSaftyInfosByDriverNo", options)
.map(res => {
return this.commonHttpService.extractData(res);
})
.catch(error => {
return this.commonHttpService.handleError(error);
});
}