Function
fetchHitokoto
(
type: SentenceType[] | SentenceType = SentenceType.文学,
)
Source from the content-addressed store, hash-verified
| 72 | '抖机灵' = 'l', |
| 73 | } |
| 74 | export const fetchHitokoto = async ( |
| 75 | type: SentenceType[] | SentenceType = SentenceType.文学, |
| 76 | ) => { |
| 77 | const json = await fetch( |
| 78 | `https://v1.hitokoto.cn/${ |
| 79 | Array.isArray(type) |
| 80 | ? `?${type.map((t) => `c=${t}`).join('&')}` |
| 81 | : `?c=${type}` |
| 82 | }`, |
| 83 | ) |
| 84 | const data = (await (json.json() as unknown)) as { |
| 85 | id: number |
| 86 | hitokoto: string |
| 87 | type: string |
| 88 | from: string |
| 89 | from_who: string |
| 90 | creator: string |
| 91 | creator_uid: number |
| 92 | reviewer: number |
| 93 | uuid: string |
| 94 | created_at: string |
| 95 | } |
| 96 | |
| 97 | return data |
| 98 | } |
Tested by
no test coverage detected