mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-23 16:34:28 -03:00
37 lines
853 B
TypeScript
37 lines
853 B
TypeScript
import { sesionStore } from '@/stores/usuario';
|
|
import type { UsersResponseDto } from '../../types';
|
|
import { apiBase } from '@/stores/url';
|
|
import { get } from 'svelte/store';
|
|
|
|
export async function obtenerSeguidoresPorUsuario(
|
|
id: string,
|
|
page: number = 1,
|
|
limit: number = 20,
|
|
fetch2?: Function
|
|
): Promise<UsersResponseDto | null> {
|
|
try {
|
|
const fetchFunc = fetch2 || fetch;
|
|
const skip = (page - 1) * limit;
|
|
|
|
const response = await fetchFunc(
|
|
`${get(apiBase)}/api/users/${id}/followers?skip=${skip}&limit=${limit}`,
|
|
{
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
|
}
|
|
}
|
|
);
|
|
|
|
if (!response.ok) {
|
|
return null;
|
|
}
|
|
|
|
const followers: UsersResponseDto = await response.json();
|
|
return followers;
|
|
} catch (error) {
|
|
return null;
|
|
}
|
|
}
|