check
This commit is contained in:
18
src/api/fetchTopHashtags.ts
Normal file
18
src/api/fetchTopHashtags.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getApiBaseUrl } from "@/components/main/BaseUrl";
|
||||
|
||||
export type TopHashtag = { tag: string; viewsCount: number };
|
||||
|
||||
// ۱۰ هشتگ برتر بر اساس مجموع بازدید در ۳۰ روز جاری — همون endpointای که اپ اندروید
|
||||
// برای فیلتر «هشتگهای برتر ماه» توی اکسپلور استفاده میکنه
|
||||
export async function fetchTopHashtags(limit = 10): Promise<TopHashtag[]> {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`${getApiBaseUrl()}/users/explore/top-hashtags?limit=${limit}`
|
||||
);
|
||||
if (!res.ok) return [];
|
||||
const data = (await res.json()) as { hashtags?: TopHashtag[] };
|
||||
return data.hashtags ?? [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user