Encrypt error: Invalid array length

Hello. Encrypt returns error: Invalid array length.

const aes = require("crypto-js/aes");

function encrypt(text, key) {
 try {
  let encryptText = aes.encrypt(text, key).toString();
  return encryptText;
 } catch (error) { console.error(error) }
}

The problem is in the variable text. Do you have an idea how to help me? Thanks!