A Promise
is async execution of the code.
You can get the value returned from that async code using .then
method on a Promise. You will have to pass the callback function which handles the value returned.
client.projects.get().then(function(foo) {
// this foo is returned from client.projects.get() async operation
})
In case that async operation threw some Exception, you can catch those using a .catch
on a promise.
client.projects.get().then(function(foo) {
// this foo is returned from client.projects.get() async operation
}).catch(function(err) {
// something went wrong while executing client.projects.get()
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…