fix: separada la logica porque daba problemas

This commit is contained in:
2025-12-03 15:01:37 -03:00
parent 24e37550ba
commit 9f0670907b

View File

@@ -4,9 +4,10 @@ import { sesionStore } from '@/stores/usuario';
import type { Post } from '../../types'; import type { Post } from '../../types';
export async function likePost(post: Post) { export async function likePost(post: Post) {
let method = post.isLiked ? "DELETE" : "POST";
try { try {
const req = await fetch(get(apiBase) + `/api/posts/${post.id}/like`, { const req = await fetch(get(apiBase) + `/api/posts/${post.id}/like`, {
method: post.isLiked ? 'DELETE' : 'POST', method: method,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
Authorization: `Bearer ${get(sesionStore)?.accessToken}` Authorization: `Bearer ${get(sesionStore)?.accessToken}`