Skip to content

Instantly share code, notes, and snippets.

@navsing
Last active November 13, 2020 06:32
Show Gist options
  • Save navsing/cae04cc829386c37481c92d194c8f580 to your computer and use it in GitHub Desktop.
Save navsing/cae04cc829386c37481c92d194c8f580 to your computer and use it in GitHub Desktop.
const path = require('path');
const fs = require('fs');
const basePathToData = path.join(__dirname, 'path-to-your-json-data-file');
const getJsonData = function (basePathToData, filename) {
var filename = path.join(basePathToData, filename);
return JSON.parse(fs.readFileSync(filename, 'utf-8'));
};
exports.getData = function (request, response) {
var data = getData(basePathToData, 'data.json');
setTimeOut(function() {
return response.send(data);
}, 100);
};
@sashadivanchik
Copy link

should there be getJsonData on line 12?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment