Answers for "how to use json schema faker"

0

how to use json schema faker

import { schema } from './mockDataSchema';
import chalk from 'chalk';

const {resolve, extend} = require('json-schema-faker');
const fs = require('fs');
extend('faker', () => require('faker'));


resolve(schema).then(sample => {
        console.log('Writing to db.json')
        fs.writeFile("./src/api/db.json", JSON.stringify(sample), function(err) {
          if(err) {
                return console.log(chalk.red(err));
          } else {
                console.log(chalk.green("Mock Data generated"));
          }
        });
      });
Posted by: Guest on June-10-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language