Merge pull request #8 from ApexDevelopment/post-editing

main
Gergő Móricz 2024-02-27 03:09:32 +01:00 committed by GitHub
commit 1c9328d7b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions

View File

@ -22,7 +22,7 @@ const cohost = require("cohost");
let [project] = await user.getProjects();
// Create Post
await cohost.Post.create(project, {
let myPostID = await cohost.Post.create(project, {
postState: 1,
headline: "hello world from cohost.js",
adultContent: false,
@ -31,6 +31,16 @@ const cohost = require("cohost");
tags: []
});
// Edit Post
await cohost.Post.update(project, myPostID, {
postState: 1,
headline: "Hello world from cohost.js!",
adultContent: false,
blocks: [],
cws: [],
tags: ["cohost.js"]
});
// Get Posts of Project
let posts = await project.getPosts();
@ -64,10 +74,10 @@ Works:
- Logging in
- Getting the posts of a project
- Creating a post
- Editing a post
Doesn't work:
- Editing a post: possible, haven't done it
- Sharing a post: possible, haven't done it
- Liking a post: possible, haven't done it
- Getting notifications: possible, haven't done it

7
lib.js
View File

@ -265,7 +265,12 @@ class Post {
return postId;
}
/** see {@link create} */
/**
*
* @param {Project} project Project to post to
* @param {string} postId ID of the post to update
* @param {PostCreate} data
*/
static async update(project, postId, data) {
await fetch(
"PUT",