L
L
Luminerys2019-06-15 20:51:43
JavaScript
Luminerys, 2019-06-15 20:51:43

Why is my async function returning a Promise {} instead of a value?

I have a function call
console.log(WebCrypto())
AND a WebCrypto function itself

export async function WebCrypto(encrypted, saveName, saveData){
  var mode = 'AES-GCM',
      length = 256,
      ivLength = 12;

  if (encrypted) {
    var result = await encrypt(saveData, saveName, mode, length, ivLength)
    return result;
  } else {
    var result = await decrypt(saveData, saveName, mode, length)
    return result;
  }
};

It should return but instead I get:
{ cipherText: ArrayBuffer, iv: Uint8Array }
Promise {<pending>}
__proto__: Promise
: "resolved"
: Object
cipherText: ArrayBuffer(30) {}
iv: Uint8Array(12) [117, 8, 180, 132, 15, 200, 70, 62, 254, 82, 38, 192]
__proto__: Object

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2019-06-15
@Luminerys

console.log(await WebCrypto())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question