store: do not panic when kv reads null
instead, return an empty string.
This commit is contained in:
parent
09081dd1d7
commit
b910f25cc7
|
@ -14,8 +14,9 @@ extern "C" {
|
|||
fn kv_put_str(key: &str, value: &str) -> Promise;
|
||||
}
|
||||
|
||||
// Returns empty string ("") if the key is not found
|
||||
pub async fn get_str(key: &str) -> MyResult<String> {
|
||||
Ok(JsFuture::from(kv_get(key)).await.internal_err()?.as_string().unwrap())
|
||||
Ok(JsFuture::from(kv_get(key)).await.internal_err()?.as_string().unwrap_or("".into()))
|
||||
}
|
||||
|
||||
pub async fn get_obj<T: DeserializeOwned>(key: &str) -> MyResult<T> {
|
||||
|
|
Loading…
Reference in a new issue