text: async function editFormHandler(event) {
      event.preventDefault();
    
      const title = document.querySelector('input[name="post-title"]').value.trim();
      const content = document.querySelector('input[name="content"]').value.trim();
      
      const id = window.location.toString().split('/')[
        window.location.toString().split('/').length -1
      ];
    
      console.log(title);
        console.log(content);
        console.log(id);
      const response = await fetch(`/api/posts/${id}`, {
        method: 'PUT',
        body: JSON.stringify({
          // post_id: id,
          title,
          content
        }),
        headers: {
          'Content-Type': 'application/json'
        }
      });
    
      if (response.ok) {
        document.location.replace('/dashboard/');
      } else {
        alert(response.statusText);
      }
    }
    
    document.querySelector('.new-post-form').addEventListener('submit', editFormHandler);