home.js 754 B

123456789101112131415161718192021222324252627
  1. export default {
  2. rendered: false,
  3. render: function(){
  4. if(!this.rendered){
  5. this.buttons();
  6. this.rendered = true;
  7. }
  8. },
  9. buttons: function(){
  10. document.getElementById("homeLogout").addEventListener("click", ()=>{
  11. fetch("/user/logout")
  12. .then(r=>r.json())
  13. .then((response)=>{
  14. if(response.error){
  15. notify("error", response.error.message);
  16. }else{
  17. changePage("login");
  18. }
  19. })
  20. .catch((err)=>{
  21. notify("error", "Something went wrong, try refreshing the page");
  22. });
  23. })
  24. }
  25. }