'use strict';

/**
 * Updates the content of a publication by ID
 * 
 * @param {int} publicationId - Publication ID to update
 */
function trash(id, element) {

    // Sending a POST request to the server 
    fetch('/publications/delete/' + id, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        body: 'identifier=' + id
    })
        .then((response) => {
            if (response.ok) {
                // Removing an element from the DOM
                element.remove();
            }
        })
        .catch((error) => {
            console.error('Ошибка:', error);
        });
}

