Document Post.update() and add it to README

pull/1/head^2
Micah 2024-02-26 20:18:38 -05:00
parent 38fff78de8
commit 8a54ab8441
2 changed files with 18 additions and 3 deletions

View File

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