We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f935630 commit 45a809bCopy full SHA for 45a809b
ebooks/book.js
@@ -3,7 +3,8 @@
3
const url = window.location && window.location.toString().split('/');
4
const bookId = url[url.length - 1].match(/(\d+)/)[0];
5
6
- if (JSON.parse(localStorage.getItem('booklist'))[bookId]) {
+ const currentList = JSON.parse(localStorage.getItem('booklist'));
7
+ if (currentList && currentList[bookId]) {
8
// book already in list
9
addbtn.html('Remove book from My Book List')
10
addbtn.css("background-color", "indianred");
@@ -31,7 +32,7 @@
31
32
bookId: bookId,
33
imgSrc: $('img.cover-art').attr('src'),
34
author: author,
- url: window.location
35
+ url: window.location.href
36
};
37
38
const newList = { ...JSON.parse(localStorage.getItem('booklist')) };
0 commit comments