Add safe mode to joke api (#3429)

* Add safe mode to joke api

* cargo fmt
This commit is contained in:
Jupp56 2023-10-02 12:20:14 +02:00 committed by GitHub
parent 443dba3cf8
commit 28e673a426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,13 +28,14 @@ pub fn emit_jokes(joke_cb: Callback<AttrValue>) {
spawn_local(async move {
loop {
// Fetch the online joke
let fun_fact = Request::get("https://v2.jokeapi.dev/joke/Programming?format=txt")
.send()
.await
.unwrap()
.text()
.await
.unwrap();
let fun_fact =
Request::get("https://v2.jokeapi.dev/joke/Programming?format=txt&safe-mode")
.send()
.await
.unwrap()
.text()
.await
.unwrap();
// Emit it to the component
joke_cb.emit(AttrValue::from(fun_fact));