Update api.js
This commit is contained in:
1 parent
7a451f2013
commit
b0ec3cd3f2
1 file changed
+9
@@ -80,6 +80,15 @@ const API = {
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async updatePost(postId, title, content) {
|
||||||
|
const data = await apiFetch('/posts/' + postId, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({ title, content })
|
||||||
|
});
|
||||||
|
if (data.error) throw new Error(data.error);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
|
||||||
async deletePost(postId) {
|
async deletePost(postId) {
|
||||||
const data = await apiFetch('/posts/' + postId, { method: 'DELETE' });
|
const data = await apiFetch('/posts/' + postId, { method: 'DELETE' });
|
||||||
if (data.error) throw new Error(data.error);
|
if (data.error) throw new Error(data.error);
|
||||||
|
|||||||
Reference in new issue
Block a user