Closed jovi-tsx closed 10 months ago
Greetings! I'm currently having an issue with nanoid at my serverless stack backend + lambda function.
import { customAlphabet } from "nanoid"; export const generateNid = () => { const nanoid = customAlphabet( "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ); const nid = nanoid(); console.log(nid); return nanoid() + new Date().getFullYear(); }; export const create = lambda(async (event) => { const body = event.body as string; const sale: Sale = JSON.parse(body); let nid = "SA" + generateNid(); let nidExists = !!(await SaleModel.scan("nid").eq(nid).exec()).count; while (nidExists) { nid = "SA" + generateNid(); nidExists = !!(await SaleModel.scan("nid").eq(nid).exec()).count; } return SaleModel.create({ id: uuid.v1(), nid, ...sale }); });
This returns sometimes that "crypto.getRandomValues() is not a function". Other times, it will work, but it will generate only "1111111111"
Greetings! I'm currently having an issue with nanoid at my serverless stack backend + lambda function.
This returns sometimes that "crypto.getRandomValues() is not a function". Other times, it will work, but it will generate only "1111111111"