in Education by
My code is about bookStore with list of books. I need to extract all data(books) from a JSON file and put them in a cardView. My code is working there I did not got any error but the data is not extracting or printing in a webpage. There is an index.html that structured the page and I wrote also cardView code in it. index.js class document.addEventListener("DOMContentLoaded", async () => { await handleLoadListValues(); }); async function getBooks(searchOptions) { let url = '/api/books/'; if (searchOptions) { url = `${url}?search-options=${searchOptions}`; } const response = await fetch(url); return response.json(); } async function handleLoadListValues(searchOptions) { try { const books = await getBooks(); document.querySelector('#books-table').innerHTML = `
${title}

This is the shorthand for flex-grow, flex-shrink and

${books.map(book => bookToHTMLRow(book)).join('')}
`; } catch (e) { console.log(e); } } function bookToHTMLRow(book) { return ` image

`; } JSON file data Example { "_id": 1, "title": "Unlocking Android", "isbn": "1933988673", "pageCount": 416, "publishedDate": { "$date": "2009-04-01T00:00:00.000-0700" }, "thumbnailUrl": "https://s3.amazonaws.com/AKIAJC5RLADLUMVRPFDQ.book-thumb-images/ableson.jpg", "shortDescription": "Unlocking Android: A Developer's Guide provides concise...", "longDescription": "Android is an open source mobile phone... ", "status": "PUBLISH", "authors": [ "W. Frank Ableson", "Charlie Collins", "Robi Sen" ], "categories": [ "Open Source", "Mobile", "java" ] }, What is wrong with my code? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
json from mocky io i test with in case not working mock another one with the same json and change the url : [ { "id": 777, "thumbnailUrl": "https://parismatch.be/app/uploads/2018/04/Macaca_nigra_self-portrait_large-e1524567086123-1100x715.jpg", "title": "balabla", "shortDescription": "jijiji" } ] i tried with fetech then I changed to axios, I corrected some html tags like:
To
${book.title}
document.addEventListener("DOMContentLoaded", async() => { await handleLoadListValues(); }); async function getBooks(searchOptions) { const books = await axios.get('http://www.mocky.io/v2/5c94e68a3600006c15941d7e') return books.data } function bookToHTMLRow(book) { return ` image
${book.title}

${book.shortDescription}

`; } async function handleLoadListValues(searchOptions) { try { const books = await getBooks(true); document.querySelector('#books-table').innerHTML = `${books.map(book => bookToHTMLRow(book)).join('')}`; } catch (e) { //console.log(e); } }
Run code snippetExpand snippet

Related questions

0 votes
    i have a json structure like that, where i would like to take from the json path the "id", but ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I have one column in my table which will store data in string format the sample data is {"pre- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I have a task coming up where I have to manually enter an HKEY_USER key value and string value for ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I have an HTML page that contains some filenames that i want to download from a webserver. I need ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    How can we write JSON data to a file?...
asked Jan 11, 2021 in Technology by JackTerrance
0 votes
    _________ extract a subset of rows from a data frame based on logical conditions. (a) rename (b) filter ( ... Analysis of R Programming Select the correct answer from above options...
asked Feb 9, 2022 in Education by JackTerrance
0 votes
    Learning RPA with UIPath. Happily extracting onscreen data from a website, processing it, using it, etc. However, ... this stage :/ Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    Download copy, extract data from an open system done fraudulently is treated as _________ (a) cyber-warfare (b) ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 4, 2021 in Education by JackTerrance
0 votes
    Which of the following is used to extract data from HTML code of websites? (a) Webscraping (b) ... questions and answers pdf, Data Science interview questions for beginners...
asked Oct 29, 2021 in Education by JackTerrance
0 votes
    ____________ is the NiFi element that is utilized to monitor incoming data, pull data from outside sources, publish data ... the options (2)Connection (3)Processor (4)Relationship...
asked Apr 18, 2021 in Technology by JackTerrance
0 votes
    I have a json file contains a icons object like this: "icons" : { "logo" : "fa fa-caret-down ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    Which of the following function programmatically extract parts of XML file? (a) XmlSApply (b) XmlApply (c) ... and answers pdf, Data Science interview questions for beginners...
asked Oct 29, 2021 in Education by JackTerrance
0 votes
    What is the benefit of Tableau Extract file over the live connection?...
asked Oct 29, 2020 in Technology by JackTerrance
0 votes
    I have an incoming json object that represents the data pulled from a database structure. I would like to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 24, 2022 in Education by JackTerrance
...