Skip to content

Instantly share code, notes, and snippets.

@coryhouse
Last active November 12, 2016 17:54
Show Gist options
  • Save coryhouse/04428d4691b0480955af740c9c1f6992 to your computer and use it in GitHub Desktop.
Save coryhouse/04428d4691b0480955af740c9c1f6992 to your computer and use it in GitHub Desktop.
Script for generating mock data using json-schema-faker and a mock data schema
/* This script generates mock data for local development.
This way you don't have to point to an actual API,
but you can enjoy realistic, but randomized data,
and rapid page loads due to local, static data.
*/
var jsf = require('json-schema-faker');
var mockDataSchema = require('./mockDataSchema');
var fs = require('fs');
var json = JSON.stringify(jsf(mockDataSchema));
fs.writeFile("./src/api/db.json", json, function (err) {
if (err) {
return console.log(err);
} else {
console.log("Mock data generated.");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment