108 lines
2.6 KiB
JavaScript

async function delItemlist(uuid) {
const apiUrl = `${currentUrl}app/delete-list`;
const postData = {
list_uuid: uuid
};
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(postData)
};
const response = await fetch(apiUrl, requestOptions)
.catch(error => {
console.error('Error during POST request:', error);
});
if (response.ok) {
console.log(response);
} else {
throw new Error('Error in server response');
}
}
async function changeListName(uuid, new_name) {
const apiUrl = `${currentUrl}app/change-list-name`;
const postData = {
uuid: uuid,
name: new_name,
};
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(postData)
};
const response = await fetch(apiUrl, requestOptions)
.catch(error => {
console.error('Error during POST request:', error);
});
if (response.ok) {
console.log(response);
} else {
throw new Error('Error in server response');
}
}
async function changeListDescription(uuid, new_description) {
const apiUrl = `${currentUrl}app/change-list-description`;
const postData = {
uuid: uuid,
description: new_description,
};
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(postData)
};
const response = await fetch(apiUrl, requestOptions)
.catch(error => {
console.error('Error during POST request:', error);
});
if (response.ok) {
console.log(response);
} else {
throw new Error('Error in server response');
}
}
async function changeListContent(uuid, new_content) {
const apiUrl = `${currentUrl}app/change-list-content`;
const content = new_content.join('#');
const postData = {
uuid: uuid,
content: content,
};
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(postData)
};
const response = await fetch(apiUrl, requestOptions)
.catch(error => {
console.error('Error during POST request:', error);
});
if (response.ok) {
console.log(response);
} else {
throw new Error('Error in server response');
}
}