const setEditModal = (isbn) => { const xhttp = new XMLHttpRequest(); xhttp.open("GET", `http://localhost:3000/book/${isbn}`, false); xhttp.send(); const book = JSON.parse(xhttp.responseText); const { title, author, publisher, publish_date, numOfPages } = book; document.getElementById('isbn').value = isbn; document.getElementById('title').value = title; document.getElementById('author').value = author; document.getElementById('publisher').value = publisher; document.getElementById('publish_date').value = publish_date; document.getElementById('numOfPages').value = numOfPages; // setting up the action url for the book document.getElementById('editForm').action = `http://localhost:3000/book/${isbn}`; } const deleteBook = (isbn) => { const xhttp = new XMLHttpRequest(); xhttp.open("DELETE", `http://localhost:3000/book/${isbn}`, false); xhttp.send(); location.reload(); } const loadBooks = () => { const xhttp = new XMLHttpRequest(); xhttp.open("GET", "http://localhost:3000/books", false); xhttp.send(); const books = JSON.parse(xhttp.responseText); for (let book of books) { const x = `
${book.title}
${book.isbn}
Author: ${book.author}
Publisher: ${book.publisher}
Number Of Pages: ${book.numOfPages}

` document.getElementById('books').innerHTML += x; } } loadBooks();