mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-01 13:10:44 -03:00
Esta api ahora tambien usa formData
This commit is contained in:
@@ -5,17 +5,16 @@ import { sesionStore } from '@/stores/usuario';
|
||||
|
||||
export async function updatePost(post: Post, callbackfn: Function, message: string) {
|
||||
try {
|
||||
const data = {
|
||||
content: post.content,
|
||||
imageUrl: post.imageUrl
|
||||
};
|
||||
const formData = new FormData();
|
||||
formData.append("content", post.content);
|
||||
formData.append("imageUrl", post.imageUrl||"");
|
||||
|
||||
const req = await fetch(get(apiBase) + `/api/posts/${post.id}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
body: formData
|
||||
});
|
||||
if (req.ok) {
|
||||
const newpost: PostResponseDto = await req.json();
|
||||
|
||||
Reference in New Issue
Block a user