How do I destructure DictionaryApiResponse
from
type std::option::Option<Vec<DictionaryApiResponse>>
The full code
...
async fn search(Request(request): Request<ApiRequest>) -> impl IntoResponse {
//destructure the request
let ApiRequest { keyword, language } = &request;
let body = reqwest::get(format!("{}/{}/{}", &DICTIONARY_API, language, keyword))
.await
.unwrap();
//error handling
let data = match body.json::<Vec<DictionaryApiResponse>>().await {
Ok(val) => Some(val),
_ => None,
};
//try to destructure the response
let data: std::option::Option<Vec<DictionaryApiResponse>> = data;
}