julien-c HF staff commited on
Commit
b851a37
1 Parent(s): 13bcdcd

Ok let's try to post a comment

Browse files
Files changed (1) hide show
  1. server.ts +14 -0
server.ts CHANGED
@@ -47,6 +47,20 @@ app.post("/", async (req, res) => {
47
 
48
  console.log(continuationText);
49
  /// Finally, let's post it as a comment in the same discussion
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  } else {
51
  console.error(`API Error`, await response.json());
52
  }
 
47
 
48
  console.log(continuationText);
49
  /// Finally, let's post it as a comment in the same discussion
50
+ const commentUrl = req.body.discussion.url.api + "/comment";
51
+
52
+ const commentApiResponse = await fetch(commentUrl, {
53
+ method: "POST",
54
+ headers: {
55
+ Authorization: `Bearer ${process.env.HF_TOKEN}`,
56
+ },
57
+ body: JSON.stringify({ comment: continuationText }),
58
+ });
59
+
60
+ const apiOutput = await commentApiResponse.json();
61
+ const apiJson = await apiOutput.json();
62
+
63
+ console.log(apiJson);
64
  } else {
65
  console.error(`API Error`, await response.json());
66
  }