Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
The following code uses promises to handle an asynchronous result
. The result
is a promise that yields an id
when resolved. This id
must be used to retrieve information from the database
. In the end, your function must return the name
property of the information. In case of an error, you have to return a rejected promise with the given error. But first you must notify the errorManager
with the error.
The given code already works. You have to rewrite it to use the async
and await
keywords.
Resolve the challenge
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function job(result, database, errorManager) {
return result
.then(function(id) {
return database.get(id);
})
.then(function(info) {
return info.name;
})
.catch(function(error) {
errorManager.notify(error);
throw error;
});
}
module.exports = job;
Enter to Rename, Shift+Enter to Preview