(&self, ctx: Ctx<'js>)
| 406 | } |
| 407 | |
| 408 | pub fn json(&self, ctx: Ctx<'js>) -> Result<Promise<'js>> { |
| 409 | let body = match self.take_body_sync(&ctx) { |
| 410 | Ok(b) => b, |
| 411 | Err(e) => return reject_with_error(&ctx, e), |
| 412 | }; |
| 413 | let ctx_clone = ctx.clone(); |
| 414 | Promise::wrap_future(&ctx, async move { |
| 415 | let bytes_opt = resolve_body_taken(&ctx_clone, body).await?; |
| 416 | if let Some(bytes) = bytes_opt { |
| 417 | return json_parse(&ctx_clone, strip_bom(bytes)); |
| 418 | } |
| 419 | Err(Exception::throw_syntax(&ctx_clone, "JSON input is empty")) |
| 420 | }) |
| 421 | } |
| 422 | |
| 423 | fn array_buffer(&self, ctx: Ctx<'js>) -> Result<Promise<'js>> { |
| 424 | let body = match self.take_body_sync(&ctx) { |
no test coverage detected