mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-01 13:10:44 -03:00
fix: separada la logica porque daba problemas
This commit is contained in:
@@ -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}`
|
||||||
|
|||||||
Reference in New Issue
Block a user