MCPcopy
hub / github.com/Innei/Shiro / fetchHitokoto

Function fetchHitokoto

src/components/modules/shared/Hitokoto.tsx:74–98  ·  view source on GitHub ↗
(
  type: SentenceType[] | SentenceType = SentenceType.文学,
)

Source from the content-addressed store, hash-verified

72 '抖机灵' = 'l',
73}
74export 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}

Callers 1

HitokotoFunction · 0.70

Calls 2

fetchFunction · 0.85
jsonMethod · 0.80

Tested by

no test coverage detected