How to access the value of a promise?

后端 未结 12 2274
予麋鹿
予麋鹿 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:27

    This example I find self-explanatory. Notice how await waits for the result and so you miss the Promise being returned.

    cryA = crypto.subtle.generateKey({name:'ECDH', namedCurve:'P-384'}, true, ["deriveKey", "deriveBits"])
    Promise {}
    cryB = await crypto.subtle.generateKey({name:'ECDH', namedCurve:'P-384'}, true, ["deriveKey", "deriveBits"])
    {publicKey: CryptoKey, privateKey: CryptoKey}
    

提交回复
热议问题