Back in the days, I remember copying and pasting any kind of text I could find in the web to fake data without smashing my keyboard. While it works, there is a much better way to have valid data without leaving your code. I'm talking about faker
. This npm
package allows you to focus specifically on the type of data. That could be a lorem, firstname, address,... or even a random hex color. There is massive data to fake so checkout the GitHub respository for the data you need.
Import faker
either with yarn
or npm
:
npm intstall faker
or yarn add faker
// import faker from "faker";
const faker = require("faker");
const fullname = faker.name.findName();
const color = faker.internet.color();
const paragraphs = faker.lorem.paragraphs(5);
Et voilà, whenever you need data, install faker and you are good to go.
Cheers,
Max