Article
Definition
- JSON
- Typescript
article.json
{
"id": 0,
"categoryID": 0,
"userID": 0,
"articleTitle": "",
"articleContent": "",
"status": 0,
"createdAt": "",
"updatedAt": "",
}
article.ts
export interface IArticle {
id: number;
categoryID: number;
userID: number;
articleTitle: string;
articleContent: string;
status: number;
createdAt: Date | null;
updatedAt: Date | null;
}
Get Articles
- Curl
- Typescript
curl -X GET "${baseUrl}/article/?filter=${filter}&orderBy=${orderBy}&page=${page}&pageSize=${pageSize}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/article/?filter=${filter}&orderBy=${orderBy}&page=${page}&pageSize=${pageSize}", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Get Article
- Curl
- Typescript
curl -X GET "${baseUrl}/article/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/article/${id}", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}