i wanted to know the best way for generating random numbers for invoice and it shouldn't be duplicated .. in my project i'm posting invoice number for each user into API and ofc i should completely avoid duplication ... is there a way to do this in Vue js?
below i tried this code but i believe it might duplicate by chance :\
const Random = '0' + Math.ceil(Math.random()*1000000)+ moment(new Date()).format('DDMMYY');
As time cannot be repeated, you can use new Date().getTime()
Use UUID v4
import { v4 as uuidv4 } from 'uuid';
invoice.id = uuidv4(); // ⇨ '14cd6bcd-bbfd-4a2d-3b5d-ab8dfcbd4dea'