Created
April 29, 2023 13:34
-
-
Save manavm1990/a6cd64914c787c1a4a127f5c0cb12541 to your computer and use it in GitHub Desktop.
Create some contacts with faker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { faker } from "@faker-js/faker"; | |
import { promises as fs } from "fs"; | |
const users = Array.from({ length: 1000 }, (_, i) => ({ | |
name: faker.name.fullName(), | |
tel: faker.phone.number("###-###-####"), | |
img: faker.image.avatar(), | |
})).map((user) => { | |
const { name } = user; | |
const [firstName, lastName] = name.split(" "); | |
return { | |
...user, | |
email: faker.internet.email(firstName, lastName), | |
}; | |
}); | |
fs.writeFile("./db.json", JSON.stringify({ users }, null, 2), "utf8"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment