29 lines
743 B
Rust
29 lines
743 B
Rust
|
use serde::{Serialize, Deserialize};
|
||
|
use reqwest::Response;
|
||
|
|
||
|
#[derive(Serialize, Deserialize, Debug)]
|
||
|
#[allow(non_snake_case)]
|
||
|
pub struct SearchResults {
|
||
|
pub id: String,
|
||
|
pub title: String,
|
||
|
pub url: String,
|
||
|
pub image: String,
|
||
|
pub releaseDate: String,
|
||
|
pub subOrDub: String,
|
||
|
}
|
||
|
#[derive(Serialize, Deserialize, Debug)]
|
||
|
#[allow(non_snake_case)]
|
||
|
pub struct Search {
|
||
|
pub currentPage: String,
|
||
|
pub hasNextPage: bool,
|
||
|
pub results: Vec<SearchResults>
|
||
|
}
|
||
|
|
||
|
pub async fn query_anime() -> Result<Search, reqwest::Error> {
|
||
|
let resp = reqwest::get("https://altoku-api.vercel.app/anime/gogoanime/mushoku?page=1")
|
||
|
.await.expect("Failed to get from API")
|
||
|
.json::<Search>()
|
||
|
.await;
|
||
|
return resp;
|
||
|
}
|