Created
November 21, 2017 11:15
-
-
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.
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
//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