Recipe can now be scheduled
This commit is contained in:
parent
ae6da1a5ae
commit
fbef990022
18 changed files with 233 additions and 51 deletions
|
|
@ -1,5 +1,8 @@
|
|||
use common::ron_api;
|
||||
use gloo::net::http::{Request, RequestBuilder};
|
||||
use gloo::{
|
||||
console::log,
|
||||
net::http::{Request, RequestBuilder},
|
||||
};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
@ -62,19 +65,23 @@ where
|
|||
{
|
||||
match request.send().await {
|
||||
Err(error) => {
|
||||
toast::show(Level::Info, &format!("Internal server error: {}", error));
|
||||
toast::show_message(Level::Info, &format!("Internal server error: {}", error));
|
||||
Err(Error::Gloo(error))
|
||||
}
|
||||
Ok(response) => {
|
||||
if !response.ok() {
|
||||
toast::show(
|
||||
toast::show_message(
|
||||
Level::Info,
|
||||
&format!("HTTP error: {}", response.status_text()),
|
||||
);
|
||||
Err(Error::Http(response.status_text()))
|
||||
} else {
|
||||
// Ok(())
|
||||
Ok(ron::de::from_bytes::<T>(&response.binary().await?)?)
|
||||
let mut r = response.binary().await?;
|
||||
// An empty response is considered to be an unit value.
|
||||
if r.is_empty() {
|
||||
r = b"()".to_vec();
|
||||
}
|
||||
Ok(ron::de::from_bytes::<T>(&r)?)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue