Skip to content

Commit

Permalink
use Array when converting bytes into JsValue (#1341)
Browse files Browse the repository at this point in the history
  • Loading branch information
skystar-p committed Oct 5, 2021
1 parent cf87893 commit 6d682b5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wasm/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use super::multipart::Form;
/// dox
use bytes::Bytes;
use js_sys::Uint8Array;
use js_sys::{Array, Uint8Array};
use std::fmt;
use wasm_bindgen::JsValue;

Expand All @@ -28,7 +28,9 @@ impl Body {
match &self.inner {
Inner::Bytes(body_bytes) => {
let body_bytes: &[u8] = body_bytes.as_ref();
let body_array: Uint8Array = body_bytes.into();
let body_uint8_array: Uint8Array = body_bytes.into();
let body_array = Array::new();
body_array.push(&body_uint8_array);
let js_value: &JsValue = body_array.as_ref();
Ok(js_value.to_owned())
}
Expand Down

1 comment on commit 6d682b5

@anlumo
Copy link

@anlumo anlumo commented on 6d682b5 Oct 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this works? I only get garbage in bodies in reqwest version 0.11.5.

image
This is supposed to be JSON.

Please sign in to comment.