0

I'm a self taught front end dev and now I'm exploring more facets of our field and I need some help connecting the dots with the backend. Apologies if this question is too broad.

I'd like to use faker.js to set up a few thousand fake users in json and have that served out to a front end project in Node JS where I could grab the data and use it in the browser.

I know how to generate one user via my data.js file and executing "node data" in the terminal:

var faker = require('faker');

var user = {
  name: faker.name.findName(),
  email: faker.internet.email(),
  address: faker.address.streetAddress(),
  bio: faker.lorem.sentence(),
  image: faker.image.avatar()
};

console.log(user);

but how would I set this up to create 2000 users for example and what is the proper way to save it (I don't want to just copy a console.log and save to a file)?

Then how would I serve that out for my front end project? I've read articles that mention serving it out through a different port but not how. Then I've read that I can use a tool like "Postman" to see that data even without my project yet.

If anyone can help me connect these dots with how or online documentation, I'd appreciate it, thanks!

nyhunter77
  • 614
  • 2
  • 7
  • 19

1 Answers1

0

without getting too deep in the code, I have some questions about your questions. :)

Is the goal here to confirm your front end works on all possible inputs? If so, you could use the faker.js client side library replacing the need to save your fake data into a db of your choice

For saving your data, I suppose you could save it to mongodb or some kind of db, but why 2000 users? Is that an arbitrary number?