Skip to content

Commit

Permalink
refactor and improve panic message
Browse files Browse the repository at this point in the history
  • Loading branch information
littlebenlittle committed Jul 18, 2024
1 parent 971f873 commit 725663f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crates/net/src/http/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,15 @@ impl Request {
let maybe_fetch =
js_sys::Reflect::get(&global, &JsValue::from_str("fetch")).unwrap();
if maybe_fetch.is_undefined() {
panic!("no global fetch()")
panic!("no supported fetch api")
}
let fetch = maybe_fetch.dyn_into::<js_sys::Function>().unwrap();
let promise = fetch
maybe_fetch
.dyn_into::<js_sys::Function>()
.unwrap()
.call1(&global, &unsafe { JsValue::from_abi(request.return_abi()) })
.map_err(js_to_error)?;
promise.dyn_into::<js_sys::Promise>().unwrap()
.map_err(js_to_error)?
.dyn_into::<js_sys::Promise>()
.unwrap()
}
};

Expand Down

0 comments on commit 725663f

Please sign in to comment.