mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-29 17:32:46 -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) {
|
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();
|
||||||
|
|||||||
Reference in New Issue
Block a user