learn-co-curriculum / fewpjs-fetch-lab Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
inedx.html is missing <script type="text/javascript" src="index.js"></script>
Also, the following code passes all test cases even though renderBooks is never called:
function fetchBooks() {
fetch('https://anapioficeandfire.com/api/books')
.then(resp => resp.json())
.then(json => console.log(json));
}
The correct code should be:
function fetchBooks() {
fetch('https://anapioficeandfire.com/api/books')
.then(resp => resp.json())
.then(json => renderBooks(json));
}
Main tag is required in index.js but missing in index.html
After completing this lab, I find that the tests do not run. I've tried to download the solution and run the tests to no avail as well.
The error I get is as follows
// ♥ Traceback (most recent call last): 9: from /Users/donnovanlyons/.rvm/gems/ruby-2.6.4/bin/learn-test:23:in
load' 7: from /Users/donnovanlyons/.rvm/gems/ruby-2.6.4/gems/learn-test-2.6.1/bin/learn-test:68:in
<top (required)>'run' 5: from /Users/donnovanlyons/.rvm/gems/ruby-2.6.4/gems/learn-test-2.6.1/lib/learn_test/runner.rb:20:in
fork'block in run' 3: from /Users/donnovanlyons/.rvm/gems/ruby-2.6.4/gems/learn-test-2.6.1/lib/learn_test/runner.rb:44:in
report_and_clean'report' 1: from /Users/donnovanlyons/.rvm/gems/ruby-2.6.4/gems/learn-test-2.6.1/lib/learn_test/reporter.rb:47:in
report'results': undefined method
[]' for nil:NilClass (NoMethodError)`Under deliverables:
In order to give them access, write you solution so that
should be "your solution"
function renderBooks(json) {
const main = document.querySelector('main')
json.forEach(book => {
const h2 = document.createElement('h2')
h2.innerHTML = `<h2>${book.name}</h2>`
main.appendChild(h2)
})
}
Some problems with this:
.json()
doesn't turn a response into JSON- it turns a JSON string into a JS object. This function should take in something like books
.<h2><h2>A Tale of Two Cities</h2></h2>
The function renderBooks
is not present, and there are no tests for this lab.
I am flagging the below as an issue because this lab seems to be an outlier.
Events Leading to Error
running learn
on my system consistently produces this error:
Error Message
/Users/home/.rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/strategies/mocha.rb:42:in `results': undefined method `[]' for nil:NilClass (NoMethodError)
Additional Testing
Even after completing the assignment correctly (confirmed by comparing my code with the solutions branch), learn
throws the same error; I initially suspected the results
error may have relied upon completion of the assignment to populate the test's results
method with an array of data from Game of Throne's API.
EDIT:
learn
, and then running npm audit fix
.Not explicit that students have access to these endpoints, or where in documentation they should look.
All the Houses in Game of Thrones
The 5th book in the series
The 1031st character in the series
#staff
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.