Tag
Definition
- JSON
- Typescript
tag.json
{
"id": 0,
"tagName": "",
"status": 0,
"createdAt": "",
"updatedAt": "",
}
tag.ts
export interface ITag {
id: number;
tagName: string;
status: number;
createdAt: Date | null;
updatedAt: Date | null;
}
Get Tags
- Curl
- Typescript
curl -X GET "${baseUrl}/tag/?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}/tag/?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 Tag
- Curl
- Typescript
curl -X GET "${baseUrl}/tag/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/tag/${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);
}
Apply Tag.ID
- Curl
- Typescript
curl -X POST "${baseUrl}/apply/tag/id/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/apply/tag/id/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Create Tag
- Curl
- Typescript
curl -X POST "${baseUrl}/tag/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @tag.json
info
tag.json
{
"tagName": "",
"status": 0,
}
tip
success status: 201
const response = await fetch("${baseUrl}/tag/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Update Tag
- Curl
- Typescript
#!/bin/bash
curl -X PUT "${baseUrl}/tag/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @tag.json
info
tag.json
{
"tagName": "",
"status": 0,
}
const response = await fetch("${baseUrl}/tag/${id}", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Patch Tag
- Curl
- Typescript
curl -X PATCH "${baseUrl}/tag/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Attrs: tagName,status" \
-d @tag.json
info
tag.json
{
"tagName": "",
"status": 0,
}
const response = await fetch("${baseUrl}/tag/${id}", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
"Attrs": "${attrs}",
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Update Tag Status
- Curl
- Typescript
curl -X PATCH "${baseUrl}/tag/${id}/status/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @tag.json
info
tag.json
{
"status": 0
}
const response = await fetch("${baseUrl}/tag/${id}/status/", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(payload),
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Destroy Tag
- Curl
- Typescript
curl -X DELETE "${baseUrl}/tag/${id}" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const response = await fetch("${baseUrl}/tag/${id}", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
Get Articles
- Curl
- Typescript
curl -X GET "${baseUrl}/tag/${id}/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}/tag/${id}/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);
}
Link Articles
- Curl
- Typescript
curl -X POST "${baseUrl}/tag/${id}/article/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "[1,2,3,4]"
const response = await fetch("${baseUrl}/tag/${id}/article/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: "[1,2,3,4]",
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}
UnLink Articles
- Curl
- Typescript
curl -X DELETE "${baseUrl}/tag/${id}/article/" \
-H "Authorization: Bearer ${accessToken}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "[1,2,3,4]"
const response = await fetch("${baseUrl}/tag/${id}/article/", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: "[1,2,3,4]",
})
const data = await response.json();
if (!response.ok) {
throw new Error(data);
}