I was trying to read and file by using a function and need to print that data from main code. Below shown is my code.
getJsonData().then(function (jsonData) {
console.log(jsonData)
})
function getJsonData(){
var fs = require('fs');
var XLSX = require('xlsx');
let contents = fs.readFileSync("test.json");
let jsonData = JSON.parse(contents);
return jsonData ;
}