title: Unable to access data from outside the scope of function
body: <p>I have a function that downloads the user input(currently named app.json) from browser(client) to the server</p>
  
  <pre><code>  function downloadUpdate(callback) {
    //Using formidable node package for downloading user input to server
    var form = new formidable.IncomingForm();
    form.on('fileBegin', function(name, file) {
      file.path = "app.json";
    });
  
    form.parse(req, function(err, fields, files) {
      res.writeHead(200, {
        'content-type': 'text/plain'
      });
      res.write('received upload:\n\n');
      res.end(util.inspect({
        fields: fields,
        files: files
      }));
    });
  
    form.on('end', function() {
      callback(null);
    });
  } 
  </code></pre>
  
  <p>I have another function that takes the file downloaded above and converts it into required format(final.json) something like this.</p>
  
  <pre><code>function UpdateCode(callback) {
      var obj = fs.readFileSync('app.json', 'utf8');
      console.log(abc); //Im getting undefined here
        var object = JSON.parse(obj);
        var data2 = [];
        for (var j = 0; j &lt; object.length; j++) {
          if (object[j].value == `${abc}`) {
            data2.push(object[j]);
          }
        }
        console.log(data2);
        fs.appendFile('final.json', JSON.stringify(data2), function(err) {
          if (err) throw err;
          console.log('Saved!');
          callback(null);
        });
      }
  </code></pre>
  
  <p>I used async series function to make them run in an order like this</p>
  
  <pre><code>async.series([
    downloadUpload,
    UpdateCode
  ], function(err, result) {
    if (err) throw err;
    else {
      console.log(result);
    }
  });
  </code></pre>
  
  <p>All of this code is inside a post request. I'm getting abc from the server</p>
  
  <pre><code>app.post('/', function(req,res){
         var abc = req.body.abc;
         console.log(abc); //I'm getting abc here
       function downloadfile(callback){
  //here goes the downloadfile definition
  }
  function UpdateCode(){
  //upload code function
  }
  //now i call async.series method
   async.series([
        downloadUpload,
        UpdateCode
      ], function(err, result) {
        if (err) throw err;
        else {
          console.log(result);
        }
      });
  });
  </code></pre>
  
  <p>the thing is the value of abc is not going to function UploadCode and when I console log abc, I get undefined. Where am I going wrong?</p>