// running tests You should log
error
to the console. // tests completed
const makeServerRequest = new Promise((resolve, reject) => {
let responseFromServer = false;
if(responseFromServer) {
resolve("We got the data");
} else {
reject("Data not received");
}
});
makeServerRequest.then(result => {
console.log(error)
});
makeServerRequest.catch(error => {
});
I would expect to see something like this:
const makeServerRequest = new Promise((resolve, reject) => {
const responseFromServer = false;
if (responseFromServer) {
resolve("We got the data");
} else {
reject("Data not received");
}
});
makeServerRequest.then((result) => {
console.log('success', result);
}).catch((error) => {
console.log('error', error);
});
First of all, the log has to be in the right code block. And I think you want to chain those.
1 Like
The code is still not passed the test, but Iām trying to fix it
This worked.
const makeServerRequest = new Promise((resolve, reject) => {
const responseFromServer = false;
if (responseFromServer) {
resolve("We got the data");
} else {
reject("Data not received");
}
});
makeServerRequest.then((result) => {
console.log('success', result);
}).catch((error) => {
console.log(error);
});
And thank you so much for the contribution
system
Closed
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.