Skip to content

Instantly share code, notes, and snippets.

@fsojitra
Created November 21, 2017 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fsojitra/b2dd3e931fc04d66befcc69b49ca8861 to your computer and use it in GitHub Desktop.
Save fsojitra/b2dd3e931fc04d66befcc69b49ca8861 to your computer and use it in GitHub Desktop.
Using Faker.js to add or display fake data into your web app or you can use it if you don't have Database but you want data to display in web app.
//you have to install two dependency "npm install express" and "npm install faker"
var express = require('express');
var faker = require('faker');
var app = express();
app.get('/', function(req, res){
//res.render('index.ejs');
res.json({
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
email: faker.internet.email(),
phone: faker.phone.phoneNumberFormat(),
city: faker.address.city(),
country: faker.address.country(),
company: faker.company.companyName()
})
});
app.listen(3000, function(){
console.log('3000');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment