Esta api ahora tambien usa formData

This commit is contained in:
2025-12-03 15:04:44 -03:00
parent 18670e62dd
commit ec852fd4d9
+5 -6
View File
@@ -5,17 +5,16 @@ import { sesionStore } from '@/stores/usuario';
export async function updatePost(post: Post, callbackfn: Function, message: string) { export async function updatePost(post: Post, callbackfn: Function, message: string) {
try { try {
const data = { const formData = new FormData();
content: post.content, formData.append("content", post.content);
imageUrl: post.imageUrl formData.append("imageUrl", post.imageUrl||"");
};
const req = await fetch(get(apiBase) + `/api/posts/${post.id}`, { const req = await fetch(get(apiBase) + `/api/posts/${post.id}`, {
method: 'PUT', method: 'PUT',
headers: { headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${get(sesionStore)?.accessToken}` Authorization: `Bearer ${get(sesionStore)?.accessToken}`
}, },
body: JSON.stringify(data) body: formData
}); });
if (req.ok) { if (req.ok) {
const newpost: PostResponseDto = await req.json(); const newpost: PostResponseDto = await req.json();