(&'env self, env: &'env Env, this: This<'env>)
| 229 | /// as the response body can only be consumed once. Subsequent calls will result in an error. |
| 230 | #[napi(ts_return_type = "Promise<Uint8Array>")] |
| 231 | pub fn bytes(&'env self, env: &'env Env, this: This<'env>) -> Result<Object<'env>> { |
| 232 | let array_buffer_promise = self.array_buffer(env, this)?; |
| 233 | let then: Function<'_, Function<Object, Unknown>, Object> = |
| 234 | array_buffer_promise.get_named_property("then")?; |
| 235 | |
| 236 | let cb = env |
| 237 | .get_global()? |
| 238 | .get_named_property::<Function<'_, String, Function<Object, Unknown>>>("eval")? |
| 239 | .call("(buf) => new Uint8Array(buf)".to_string())?; |
| 240 | |
| 241 | then.apply(Some(&array_buffer_promise), cb) |
| 242 | } |
| 243 | |
| 244 | /// Returns the response body as a string. |
| 245 | /// |
no test coverage detected