rust-fetch 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
use wasm_bindgen::prelude::*;
|
|
2
2
|
use wasm_bindgen::JsValue;
|
|
3
3
|
// use wasm_bindgen_futures::JsFuture;
|
|
4
|
-
use serde_json::Value;
|
|
5
4
|
use reqwest::get;
|
|
5
|
+
use serde_json::Value;
|
|
6
6
|
use serde_wasm_bindgen::to_value;
|
|
7
7
|
// use wasm_bindgen::prelude::*;
|
|
8
8
|
use wasm_bindgen_futures::future_to_promise;
|
|
@@ -12,7 +12,7 @@ use js_sys::Promise;
|
|
|
12
12
|
use wasm_bindgen_futures::js_sys;
|
|
13
13
|
|
|
14
14
|
#[wasm_bindgen]
|
|
15
|
-
pub fn fetch_wasm_json_new(url: String) -> Promise {
|
|
15
|
+
pub async fn fetch_wasm_json_new(url: String) -> Promise {
|
|
16
16
|
future_to_promise(async move {
|
|
17
17
|
let response = get(url)
|
|
18
18
|
.await
|
|
@@ -23,8 +23,7 @@ pub fn fetch_wasm_json_new(url: String) -> Promise {
|
|
|
23
23
|
.await
|
|
24
24
|
.map_err(|e| JsValue::from_str(&e.to_string()))?;
|
|
25
25
|
|
|
26
|
-
serde_wasm_bindgen::to_value(&json)
|
|
27
|
-
.map_err(|e| JsValue::from_str(&e.to_string()))
|
|
26
|
+
serde_wasm_bindgen::to_value(&json).map_err(|e| JsValue::from_str(&e.to_string()))
|
|
28
27
|
})
|
|
29
28
|
}
|
|
30
29
|
|
|
@@ -82,5 +81,6 @@ pub async fn fetch_wasm_api() -> Result<JsValue, JsValue> {
|
|
|
82
81
|
.map_err(|e| JsValue::from_str(&e.to_string()))?;
|
|
83
82
|
|
|
84
83
|
// Ok(content)
|
|
85
|
-
Ok(to_value(&content)?)
|
|
84
|
+
// Ok(to_value(&content)?)
|
|
85
|
+
Ok(to_value::<serde_json::Value>(&content)?)
|
|
86
86
|
}
|
package/wasm-module/src/lib.rs
CHANGED