Advertisement
sumakaki

send-coment

Nov 19th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // отправка коментария
  2. async function sendRequstComent(body, headers) {
  3.     try{
  4.         let response = await fetch('coment.php', {
  5.             method: 'POST',
  6.             body: JSON.stringify(body),
  7.             headers: headers,
  8.         });
  9.          let data = await response.json();
  10.     } catch (e) {
  11.         console.error(e);
  12.     }
  13. }
  14.  
  15.  
  16.  
  17.  
  18. // отправка коментария
  19.  let inputComent = formComent[2]
  20.  inputComent.addEventListener('click', (headers) => {
  21.     let body = {
  22.         'userName': formComent.username.value,
  23.         'coment': formComent.coment.value
  24.     };
  25.  
  26.     sendRequstComent(body, headers).then(console.log(data));
  27.  });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement