0

in this code, the anonymous function of the readFile function returns a value. What i want to do is get that return value to a separate variable.

var jsonfile = require('jsonfile');

var file = '../data/tc.json';

jsonfile.readFile(file, function (error, data) {
    return data;
  });
s1n7ax
  • 2,750
  • 6
  • 24
  • 53
  • `readFile` is `asynchronous`.. Instead of doing `return`, use it or pass it as argument for another `function` – Rayon Apr 21 '16 at 10:42
  • See also: [Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](http://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron) – James Thorpe Apr 21 '16 at 10:42

0 Answers0