Skip to content

Instantly share code, notes, and snippets.

@manavm1990
Created April 29, 2023 13:34
Show Gist options
  • Save manavm1990/a6cd64914c787c1a4a127f5c0cb12541 to your computer and use it in GitHub Desktop.
Save manavm1990/a6cd64914c787c1a4a127f5c0cb12541 to your computer and use it in GitHub Desktop.
Create some contacts with faker
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