'use strict';

/**
 * Rotates the page of a book and reloads the page if necessary
 * 
 * @param {number} identifier - Book ID
 * @param {number} page - Page number to rotate
 * @param {boolean} [reload=false] - Whether to reload the page after rotation
 * 
 * @returns {void}
 */
function rotate(id, page, reload = false) {
    if (typeof id === 'number' && typeof page === 'number') {
        // Получены входные параметры

        // Запрос
        fetch(`/books/${id}/${page}/rotate`, {
            method: 'POST'
        }).then((response) => response.text()
        ).then(
            (response) => {
                location.reload();

            }
        );
    }
}