本文整理汇总了TypeScript中angular2-jwt/angular2-jwt.AuthHttp.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AuthHttp.get方法的具体用法?TypeScript AuthHttp.get怎么用?TypeScript AuthHttp.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2-jwt/angular2-jwt.AuthHttp
的用法示例。
在下文中一共展示了AuthHttp.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
this._userService.getUser('http://localhost:8080/api/accounts/' + userId).subscribe(user => {
currUser = user;
this._http.get(url_frequency, options)
.map(res => {
let result = res.json();
return result.frequency;
})
.catch(err => {
let errMsg = err.message || 'Unkown error';
return Observable.throw(errMsg);
})
.subscribe(
result => {
frequency = result;
observer.next({
name: 'temperature_optimization',
url: 'http://klimaoptimierungsservice.eu-gb.mybluemix.net/api/temperature_optimization',
frequency: frequency,
mostActiveUser: currUser
});
}
);
});
示例2:
result => {
frequency = result;
this._http.get(url_usage, options)
.flatMap(res => {
let result = res.json();
if (isArray(result)) {
return this.getMostActiveUser(result);
} else {
throw new Error;
}
})
.catch(err => {
let errMsg = err.message || 'Unkown error';
return Observable.throw(errMsg);
})
.subscribe(
user => {
mostActiveUser = user;
observer.next({
name: 'temperature_optimization',
url: 'http://klimaoptimierungsservice.eu-gb.mybluemix.net/api/temperature_optimization',
frequency: frequency,
mostActiveUser: mostActiveUser
});
}
);
}
示例3: 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());
}
}
示例4: getEvents
/**
* Get a list of events located at eventsURL
* @param eventsURL
* @returns {Observable<R>}
*/
public getEvents(eventsURL:string):Observable<Event[]> {
return this._http.get(eventsURL).map(res => {
let body = res.json();
return body.items.map((eventJSON) => {
return new Event(eventJSON);
});
});
}
示例5: Headers
return new Observable<Api>((observer:Observer<Api>) => {
let options = {
headers: new Headers({'Content-Type': 'application/json'})
};
// let url_frequency = 'http://localhost:8080/api/tracking/temperature_optimization/occurence';
// let url_usage = 'http://localhost:8080/api/tracking/temperature_optimization';
let frequency = 0;
let mostActiveUser:User;
this._http.get(url_frequency, options)
.map(res => {
let result = res.json();
return result.frequency;
})
.catch(err => {
let errMsg = err.message || 'Unkown error';
return Observable.throw(errMsg);
})
.subscribe(
result => {
frequency = result;
this._http.get(url_usage, options)
.flatMap(res => {
let result = res.json();
if (isArray(result)) {
return this.getMostActiveUser(result);
} else {
throw new Error;
}
})
.catch(err => {
let errMsg = err.message || 'Unkown error';
return Observable.throw(errMsg);
})
.subscribe(
user => {
mostActiveUser = user;
observer.next({
name: 'temperature_optimization',
url: 'http://klimaoptimierungsservice.eu-gb.mybluemix.net/api/temperature_optimization',
frequency: frequency,
mostActiveUser: mostActiveUser
});
}
);
}
);
});
示例6: getUser
/**
* Fetches a user resource located at url
* @param url URL to the user resource
* @return
*/
getUser(url:string):Observable<User> {
return this._http.get(url)
.map(res => {
if (200 == res.status) {
return new User(res.json());
} else if (401 == res.status) {
throw new Error("Authorization failed: current user is not allowed to access this resource.");
} else {
throw new Error("Unknown error");
}
}).catch(err => {
let errMsg = err.message || 'Unknown error';
return Observable.throw(errMsg);
});
}
示例7: getConfirmationEmail
getConfirmationEmail(user: User): Observable<any> {
return this.authHttp.get('/api/users/'+user.name+'/email-confirm/require')
.map(res => {
let result = res.json();
if (result.success) {
return {text:result.text}
} else {
return {text:"No email was found! Please request new Email!"};
}
})
.catch(err => {
let errMsg = err.message || 'Unkown error';
return Observable.throw(errMsg);
});
}
示例8: getUserSetting
getUserSetting(user:User):Observable<Settings> {
// let url = 'http://localhost:8080' + user.id + '/settings';
let url = 'http://klimaoptimierungsservice.eu-gb.mybluemix.net' + user.id + '/settings';
return this._http.get(url)
.map(res => {
if (res.status == 200) {
let settings = res.json().settings;
// return settings;
return new Settings(settings.temp, settings.brightness, settings.humidity);
} else {
return Observable.throw('Unknown error');
}
})
.catch(err => {
let errMsg = err.message || 'Unkown error';
return Observable.throw(errMsg);
});
}
示例9: getUser
getUser(uri:string):Observable<User> {
return this._http.get(uri)
.map(res => {
if (res.status == 200) {
let result = res.json();
return new User(result.uri, result.name, result.email, result.admin, result.confirmed,result.PRrequested);
} else if (res.status == 403) {
throw new Error("Authorization failed: current user is not allowed to access this resource.");
} else {
throw new Error("Unknown error");
}
})
.catch(err => {
let errMsg = err.message || 'Unknown error';
return Observable.throw(errMsg);
});
}
示例10: getUsers
getUsers():Observable<any> {
return this._http.get('/api/admin/users')
.map(res => {
if (res.status == 200) {
let result = res.json();
let users = [];
result.forEach(user => {
let newUser = new User(user.name, user.name, user.email, user.admin, user.confirmed, user.PRrequested);
users.push(newUser);
});
return users;
} else {
throw new Error("Unknown Error!");
}
})
.catch(err => {
let errMsg = err.message || 'Unkown error';
return Observable.throw(errMsg);
});
}