-
I have a database query that can optionally be None, other than returning |
Beta Was this translation helpful? Give feedback.
Answered by
sunli829
Dec 21, 2022
Replies: 1 comment 1 reply
-
You have two ways: async fn load_rows(&self) -> Result<Option<Json<Vec<Value>>>> {
...
} Return error code directlyasync fn get(&self) -> Result<Json<Vec<Value>>> {
let res = load_rows().await?;
res.ok_or_else(|| poem::Error::from_status(StatusCode::NO_CONTENT))
} Define the response using the
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ShayBox
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have two ways:
Return error code directly
Define the response using the
ApiResponse
macroRecommended, response status codes are shown in the documentation