mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-20 16:17:32 -03:00
actualizada interfaz de seguidos y seguidores
This commit is contained in:
22
src/lib/hooks/obtenerCantidadDeSeguidores.ts
Normal file
22
src/lib/hooks/obtenerCantidadDeSeguidores.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { apiBase } from '@/stores/url';
|
||||
import { sesionStore } from '@/stores/usuario';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export async function obtenerCantidadDeSeguidores(id: string, fetch2?: Function) {
|
||||
const fetchFn = fetch2 || fetch;
|
||||
try {
|
||||
const response = await fetchFn(`${get(apiBase)}/api/users/${id}/followers/count`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return 0;
|
||||
}
|
||||
return await response.json();
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
22
src/lib/hooks/obtenerCantidadDeSeguidos.ts
Normal file
22
src/lib/hooks/obtenerCantidadDeSeguidos.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { apiBase } from '@/stores/url';
|
||||
import { sesionStore } from '@/stores/usuario';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export async function obtenerCantidadDeSeguidos(id: string, fetch2?: Function) {
|
||||
const fetchFn = fetch2 || fetch;
|
||||
try {
|
||||
const response = await fetchFn(`${get(apiBase)}/api/users/${id}/following/count`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return 0;
|
||||
}
|
||||
return await response.json();
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user