fix gravatar url, format code
use failure::Error;
-use yew::format::{Nothing, Json};
-use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::callback::Callback;
+use yew::format::{Json, Nothing};
+use yew::services::fetch::{FetchService, FetchTask, Request, Response};
#[derive(Deserialize, Debug)]
pub struct Profile {
@@ -31,14 +31,17 @@ impl GravatarService {
}
pub fn profile(&mut self, hash: &str, callback: Callback<Result<Profile, Error>>) -> FetchTask {
- let url = format!("https://gravatar.com/{}", hash);
+ let url = format!("https://en.gravatar.com/{}.json", hash);
let handler = move |response: Response<Json<Result<Profile, Error>>>| {
let (meta, Json(data)) = response.into_parts();
if meta.status.is_success() {
callback.emit(data)
} else {
// format_err! is a macro in crate `failure`
- callback.emit(Err(format_err!("{}: error getting profile https://gravatar.com/", meta.status)))
+ callback.emit(Err(format_err!(
+ "{}: error getting profile https://gravatar.com/",
+ meta.status
+ )))
}
};
let request = Request::get(url.as_str()).body(Nothing).unwrap();
