summaryrefslogtreecommitdiff
path: root/examples/async_http_reqwest.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2021-06-03 23:52:29 +0100
committerAlex Orlenko <zxteam@protonmail.com>2021-06-03 23:52:29 +0100
commit6c0096d8ac6d97c433dd7827e747d0e9464fb84e (patch)
tree03ef494fd5f8916f578f164005e8c9cc16a21b78 /examples/async_http_reqwest.rs
parentabb95c3c56aaf9b084dd5e6d01f8147554c8a0bd (diff)
downloadmlua-6c0096d8ac6d97c433dd7827e747d0e9464fb84e.zip
Update examples
Diffstat (limited to 'examples/async_http_reqwest.rs')
-rw-r--r--examples/async_http_reqwest.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/examples/async_http_reqwest.rs b/examples/async_http_reqwest.rs
index e80051a..b7a199c 100644
--- a/examples/async_http_reqwest.rs
+++ b/examples/async_http_reqwest.rs
@@ -1,4 +1,4 @@
-use mlua::{Error, Lua, LuaSerdeExt, Result};
+use mlua::{ExternalResult, Lua, LuaSerdeExt, Result};
#[tokio::main]
async fn main() -> Result<()> {
@@ -10,11 +10,8 @@ async fn main() -> Result<()> {
let resp = reqwest::get(&uri)
.await
.and_then(|resp| resp.error_for_status())
- .map_err(Error::external)?;
- let json = resp
- .json::<serde_json::Value>()
- .await
- .map_err(Error::external)?;
+ .to_lua_err()?;
+ let json = resp.json::<serde_json::Value>().await.to_lua_err()?;
lua.to_value(&json)
})?;
globals.set("fetch_json", fetch_json)?;