//api/User/Posts?username=<string>&page=1&pageSize=10
const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("//api/User/Posts?username=<string>", 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": "/images/defaultAvatar.png",
"content": "这是第一篇帖子",
"favoriteNums": 0,
"likeNums": 0,
"createdAt": "2025-01-22T14:09:56"
}
]
}
//api/User/Info?username=<string>
const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("//api/User/Info?username=<string>", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
{
"id": 1,
"username": "admin",
"nickname": "admin imarket",
"avatar": "test",
"status": 1
}