mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-06 14:00:43 -03:00
27 lines
634 B
TypeScript
27 lines
634 B
TypeScript
import { sesionStore } from '@/stores/usuario';
|
|
import { get } from 'svelte/store';
|
|
import type { Post } from '../../types';
|
|
import { apiBase } from '@/stores/url';
|
|
|
|
export async function esSeguido(post: Post) {
|
|
if (!get(sesionStore)?.accessToken || post.authorName === '[deleted]') return;
|
|
|
|
const id = post.authorId;
|
|
try {
|
|
const response = await fetch(`${get(apiBase)}/api/users/${id}/is-following`, {
|
|
headers: {
|
|
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
|
}
|
|
});
|
|
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
return data;
|
|
} else {
|
|
return false;
|
|
}
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|