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