add new endpoint for tariffs
This commit is contained in:
@@ -65,4 +65,38 @@ export async function getUserFilesInfo() {
|
||||
} catch (error) {
|
||||
console.error(`error: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchTariffs() {
|
||||
const token = await getSessionData('token');
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
version: 1,
|
||||
msg_id: 30001,
|
||||
message_body: {
|
||||
action: 'get',
|
||||
user_token: token
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const parsed = await response.json()
|
||||
if (parsed?.message_code === 0) {
|
||||
return parsed.message_body?.tariffs;
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('error');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user