Book Search App with OpenLibrary API and LocalStorage
Classified in Computers
Written on in
English with a size of 8.38 KB
Obtener elementos del DOM
const resultsContainer = document.getElementById('results');
const favoritesContainer = document.getElementById('favorites');
const readContainer = document.getElementById('read');
Buscar libros en OpenLibrary usando fetch().then()
function fetchBooks(query, limit = 10, callback) {
fetch(`https://openlibrary.org/search.json?q=${encodeURIComponent(query)}&limit=${limit}`)
.then(res => res.json())
.then(data => {
const books = data.docs || [];
callback(books);
})
.catch(err => {
console.error("Error fetching books:", err);
});
}
Guardar en localStorage si no está duplicado
function saveToLocalStorage(key, book) {
const stored
