From 4c09b8e3cdb3e1c9b913bc23767f6aed0447c1f2 Mon Sep 17 00:00:00 2001 From: SkyfallWasTaken Date: Mon, 1 Jul 2024 19:36:17 +0100 Subject: [PATCH] Push to Slack Webhook --- Cargo.lock | 1 + Cargo.toml | 1 + src/lib.rs | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 603f754..73bc1e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,6 +39,7 @@ dependencies = [ "indoc", "scraper", "serde", + "serde-wasm-bindgen 0.6.5", "serde_json", "worker", "worker-macros", diff --git a/Cargo.toml b/Cargo.toml index 1e41752..d84a703 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,3 +22,4 @@ indoc = "2.0.5" # We don't use getrandom, but we enable the "js" feature to enable # WebAssembly support. getrandom = { version = "0.2", features = ["js"] } +serde-wasm-bindgen = "0.6.5" diff --git a/src/lib.rs b/src/lib.rs index 853b88e..616d9bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,11 +64,11 @@ async fn run_scrape(env: Env) -> Result { let request = Request::new_with_init( &webhook_url, RequestInit::new() - .with_body(json!({ - "text": message, - })) + .with_body(Some(serde_wasm_bindgen::to_value( + &json!({ "text": message }), + )?)) .with_method(Method::Post), - ); + )?; Fetch::Request(request).send().await?; }