|
function getData(cb) { |
|
fetch("/getquestions") |
|
.then(response => { |
|
if (response.status !== 200) { |
|
console.log( |
|
"Looks like there was a problem. Status Code: " + response.status |
|
); |
|
return; |
|
} |
|
return response.json(); |
|
}) |
|
.then((myJson) => { |
|
return(cb(myJson)); |
|
}) |
|
.catch(err => { |
|
console.log("Fetch Error :-S", err); |
|
}); |
|
} |
when the response status is !200 it will return undefined to the next .then
do you want this to happen ?
return(cb(undefined));
maybe throw error ? or send error in the call back ?
GeekWars/public/scripts/fetch.js
Lines 1 to 18 in ec2ffab
when the response status is !200 it will return undefined to the next .then
do you want this to happen ?
return(cb(undefined));maybe throw error ? or send error in the call back ?