Monday, 1 May 2017

TypeError: this.json is not a function

I have a js file:

var fs = require('fs');

function json(context) {
  return JSON.stringify(JSON.parse(context), null, 2);
}


var myHelpers = {
  json_data: function() {
    return json(fs.readFileSync('file.json', {encoding: 'utf8'}));
  }
};

Getting error in line return json(fs.readFileSync('file.json', {encoding: 'utf8'})); saying TypeError: json is not a function

How would you fix that? and why it is happens?



via sreginogemoh

No comments:

Post a Comment