Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/backend/StringOperation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import axios from 'axios';

let token = localStorage.getItem('token');
let ip = localStorage.getItem('ip');
let port = localStorage.getItem('port');

function loadData(){
token = localStorage.getItem('token');
ip = localStorage.getItem('ip');
port = localStorage.getItem('port');
}

// Delete a specific kV
export async function DeleteSingleValue(bucket: string, key: string): Promise<any> {
loadData()
const Url = `http://${ip}:${port}`;
return await axios.delete(
`${Url}/string/delete/${bucket}/${key}?token=${token}`,
);
}

// Update a specific kV
export async function UpdateSingleValue(bucket: string, key: string, value: string,ttl:number): Promise<any> {
loadData()
const Url = `http://${ip}:${port}`;
return await axios.post(
`${Url}/string/update/${bucket}/${key}?token=${token}`,
{
value: value,
ttl: ttl
}
);
}

// Add a specific kV
export async function AddSingleValue(bucket: string, key: string, value: string,ttl:number): Promise<any> {
loadData()
const Url = `http://${ip}:${port}`;
return await axios.post(
`${Url}/string/update/${bucket}/${key}?token=${token}`,
{
value: value,
ttl: ttl
}
);
}
Loading