use Array when converting bytes into JsValue (#1341)

This commit is contained in:
Jaehyeon Park
2021-10-05 09:16:41 +09:00
committed by GitHub
parent cf87893b17
commit 6d682b53e2

View File

@@ -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;
@@ -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())
}