Initial draft of comments
This commit is contained in:
parent
5916a21bd5
commit
edb7ef2fc4
5 changed files with 164 additions and 13 deletions
|
|
@ -16,6 +16,17 @@ export interface Post extends NewPost {
|
|||
votes: Votes;
|
||||
}
|
||||
|
||||
export interface NewComment {
|
||||
content: string;
|
||||
user_token: string;
|
||||
parent_post_id: number;
|
||||
}
|
||||
|
||||
export interface Comment extends NewComment {
|
||||
content: string;
|
||||
token: string;
|
||||
}
|
||||
|
||||
// This is what the login and registration responses look like
|
||||
export interface AuthResponse {
|
||||
username: string;
|
||||
|
|
@ -56,6 +67,16 @@ export async function createPost(post: NewPost): Promise<void> {
|
|||
});
|
||||
}
|
||||
|
||||
export async function createComment(comment: NewComment): Promise<void> {
|
||||
await fetch("/api/comments", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(comment),
|
||||
});
|
||||
}
|
||||
|
||||
// Gets the comments for a specific post
|
||||
export async function getComments(
|
||||
postId: string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue