add token for fetch violation list

This commit is contained in:
smanylov
2026-03-18 18:09:33 +07:00
parent 89e288c591
commit 9907213dd8
4 changed files with 67 additions and 2 deletions
+40 -1
View File
@@ -148,6 +148,7 @@ export async function fetchViolationStats() {
}
export async function getFileViolations(fileId: string, page: number) {
const token = await getSessionData('token');
try {
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
@@ -159,7 +160,8 @@ export async function getFileViolations(fileId: string, page: number) {
file_id: fileId,
page: page,
size: 5,
sort_direction: "desc"
sort_direction: "desc",
token: token
}
}),
headers: {
@@ -182,4 +184,41 @@ export async function getFileViolations(fileId: string, page: number) {
} catch (error) {
return null
}
}
export async function fetchViolationGeography() {
const token = await getSessionData('token');
/* "group_by": "tld" */
try {
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
method: 'POST',
body: JSON.stringify({
version: 1,
msg_id: 30009,
message_body: {
group_by: "domain",
token: token
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
});
if (response.ok) {
let parsed = await response.json();
if (parsed) {
return parsed;
} else {
throw null;
}
} else {
throw (`${response.status}`);
}
} catch (error) {
return null
}
}