I am using a code like the following:
let books = {
1: {"author": "Chinua Achebe","title": "Things Fall Apart", "reviews": {} },
2: {"author": "Samuel Beckett","title": "Molloy, Malone Dies, The Unnamable, the trilogy", "reviews": {} }
}
booklist = Object.values(books);
let the_book = booklist[book_index];
book_index is set from the isbn:
public_access.get('/review/:isbn',function (req, res) {
let book_index = parseInt(req.params.isbn);
book_index -=1;
let the_book = booklist[book_index];
console.log(the_book) Returns one key/value pair based on the value of isbn
});
I have tried different ways of accessing individual key/value pairs within the_book and nothing has worked so far. I cannot find the correct syntax for it.
I checked and confirmed that the_book
is properly initialized and has values.