So I have read bot the asyncronous functions and fetch() articles. In both we can see functions like this:
fetch('products.json')
.then( response => {
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
return response.json();
})
.then( json => initialize(json) )
.catch( err => console.error(`Fetch problem: ${err.message}`) );
My question is, what is this response
word in line 2 or json
in line 8 (I know what json is, but why is the term thrown in there)? Is this an arbitrary term? Where does it come from and what is it’s purpose?
I did the task for the asyncronous funtions chapter, completely removed the word “response”, used and empty ()
instead, and the app continued working (codepen here)
Can you clarify this for me please?