Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var fs = require("fs");
  2.     var test = function(cb) {
  3.         var Copiers = {'follow': ['2215546130',  '2785638816']};
  4.         fs.exists ("BBDD.txt", function(exists){
  5.         if (exists){
  6.             fs.readFile("BBDD.txt", 'utf8', function(err, data){
  7.                 if (err){
  8.                     cb(err, null);
  9.                 } else {
  10.                     var json = JSON.parse(data);
  11.                     console.log(Copiers);
  12.                     var x = json.length;
  13.                     for (i=0; i<x; i++){
  14.                         Copiers.follow.push(json[i].id);
  15.                     }
  16.                     cb(null, Copiers);
  17.                 }
  18.             })
  19.         } else{
  20.             cb("No existe el fichero", null);
  21.         }
  22.     });
  23.        
  24. test(function (err, res) {
  25.     if (err) {
  26.         console.log("Error!");
  27.         console.error(err);
  28.     } else {
  29.         console.log(require('util').inspect(res));
  30.     }
  31. });
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement