const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("//api/Comments/:postid", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
{
"success": true,
"comments": [
{
"id": 321,
"nickname": "admin imarket",
"username": "admin",
"userAvatar": "test",
"content": "这是第一个评论",
"isLike": false,
"likeNum": 0,
"createdAt": "2025-01-22T16:58:20"
}
]
}
{
"content": "<string>",
"postId": "<ulong>"
}
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "<API Key>");
const raw = JSON.stringify({
"content": "<string>",
"postId": "<ulong>"
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("//api/Comments/Create", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
{
"success": true,
"commentId": 12
}
//api/Comments/Delete?commentId=<ulong>
const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("//api/Comments/Delete?commentId=<string>", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
//api/Comments/Like?commentId=<ulong>
const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("//api/Comments/Like?commentId=<string>", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
//api/Comments/UnLike?commentId=<ulong>
const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("//api/Comments/UnLike?commentId=<ulong>", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));