Last active
November 13, 2020 06:32
-
-
Save navsing/cae04cc829386c37481c92d194c8f580 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
should there be getJsonData on line 12?