let answerServer = '';
let gradeForm = document.querySelector('.paper__info-grade');
const sendData = async(url, data) => {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8',
'X-CSRF-Token': token,
},
body: JSON.stringify(data),
})
if (!response.ok) {
throw new Error('Error!')
}
answerServer = await response.json();
gradeForm.innerHTML = answerServer.status_text;
};
function sendRating(id, stars) {
const data = {
blog_id: id,
voting_rating: stars,
}
sendData('/blogs_voting', data);
}