How to access the value of a promise?

后端 未结 12 2552
予麋鹿
予麋鹿 2020-11-22 06:55

I\'m looking at this example from Angular\'s docs for $q but I think this probably applies to promises in general. The example below is copied verbatim from the

12条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 07:30

    There are some good answer above and here is the ES6 Arrow function version

    var something = async() => {
       let result = await functionThatReturnsPromiseA();
       return result + 1;
    }
    

提交回复
热议问题