mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-13 15:10:43 -03:00
skeleton de la interfaz de seguidores y seguidos
This commit is contained in:
25
src/lib/hooks/obtenerSeguidoresPorUsuario.ts
Normal file
25
src/lib/hooks/obtenerSeguidoresPorUsuario.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { sesionStore } from "@/stores/usuario";
|
||||
import type { UserResponseDto } from "../../types";
|
||||
import { get } from "svelte/store";
|
||||
import { apiBase } from "@/stores/url";
|
||||
|
||||
export async function obtenerSeguidoresPorUsuario(Id: string): Promise<UserResponseDto[] | null> {
|
||||
try {
|
||||
const response = await fetch(`${get(apiBase)}/api/users/${Id}/followers`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const followers: UserResponseDto[] = await response.json();
|
||||
return followers;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
25
src/lib/hooks/obtenerSeguidosPorUsuario.ts
Normal file
25
src/lib/hooks/obtenerSeguidosPorUsuario.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { sesionStore } from "@/stores/usuario";
|
||||
import type { UserResponseDto } from "../../types";
|
||||
import { apiBase } from "@/stores/url";
|
||||
import { get } from "svelte/store";
|
||||
|
||||
export async function obtenerSeguidosPorUsuario(id: string): Promise<UserResponseDto[] | null> {
|
||||
try {
|
||||
const response = await fetch(`${get(apiBase)}/api/users/${id}/following`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const users: UserResponseDto[] = await response.json();
|
||||
return users;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user