//api/Search/Posts?keyWord=<string>&page=1&pageSize=10
const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("//api/Search/Posts?keyWord=<string>&page=1&pageSize=10", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
{
"success": true,
"posts": [
{
"id": 1,
"title": "第一个帖子",
"nickname": "admin imarket",
"avatar": "test",
"content": "这个是第一个帖子",
"favoriteNums": 1,
"likeNums": 0,
"createdAt": "2025-01-22T16:41:31"
}
]
}
返回值为最近一周的最多点赞和最多收藏10篇帖子,如果帖子没有点赞或收藏,则可能少于10篇
const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("//api/Search/HotRanking", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
{
"success": true,
"like": [
{
"id": 1,
"title": "第一个帖子",
"content": "这个是第一个帖子",
"userId": 3214,
"createdAt": "2025-01-22T16:41:31",
"likeCount": 1
}
],
"favorite": [
{
"id": 2,
"title": "第一个帖子",
"content": "这个是第一个帖子",
"userId": 3214,
"createdAt": "2025-01-22T16:41:31",
"favoriteCount": 1
}
]
}