Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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