diff --git a/examples/tutorial/src/routes/index.rs b/examples/tutorial/src/routes/index.rs index 14a47f6e..1c2ed45a 100644 --- a/examples/tutorial/src/routes/index.rs +++ b/examples/tutorial/src/routes/index.rs @@ -24,7 +24,7 @@ async fn get_all_pokemons(_req: Request<'_>, fetch: reqwest::Client) -> Response Response::Props(Props::new(data)) } Err(_err) => Response::Props(Props::new_with_status( - Pokemons { results: vec![] }, + "{}", // Return empty JSON StatusCode::INTERNAL_SERVER_ERROR, )), }; diff --git a/examples/tutorial/src/routes/pokemons/[pokemon].rs b/examples/tutorial/src/routes/pokemons/[pokemon].rs index 7be62583..7b6275d7 100644 --- a/examples/tutorial/src/routes/pokemons/[pokemon].rs +++ b/examples/tutorial/src/routes/pokemons/[pokemon].rs @@ -19,16 +19,15 @@ async fn get_pokemon(req: Request<'_>, fetch: reqwest::Client) -> Response { return match fetch.get(format!("{POKEMON_API}/{pokemon}")).send().await { Ok(res) => { + if res.status() == StatusCode::NOT_FOUND { + return Response::Props(Props::new_with_status("{}", StatusCode::NOT_FOUND)); + } + let data = res.json::().await.unwrap(); Response::Props(Props::new(data)) } Err(_err) => Response::Props(Props::new_with_status( - Pokemon { - name: "Nope".to_string(), - id: 0, - weight: 0, - height: 0, - }, + "{}", StatusCode::INTERNAL_SERVER_ERROR, )), };