Processing from NodeJS to JSON

0

I am trying to process from NodeJS to JSON, the idea is to develop an "autocomplete" text field with AngulaJS, but I am with the problem that the driver does not work correctly to be able to show the data in the HTML. I was testing it with w3schools and it works fine:

$http({url: "http://www.w3schools.com/angular/customers.php", 
           method: "GET",
           params: {value: $scope.usuario}
      }).success(function(usuarios) {
        $scope.usuarios = usuarios.records;

      });

But when I put the path (localhost: 3000) of the file nodeJS or php (I have tried everything), it does not compile me to JSON, therefore I can not make the "autocomplete" work. I know that the php and node script are fine, but I find it strange that instead of giving me an array, it shows me the complete code in plain text. Greetings and thanks in advance !!!!

    
asked by Nahuel Jakobson 20.08.2016 в 05:45
source

1 answer

0

The result was as simple as placing

fs.writeFile('./views/jsondb/jsonfile.json', JSON.stringify(rows), function (err) {
    if (err) throw err;
    console.log('json creado!');

}); 

And then call the route from angular with $ http.

Greetings

    
answered by 21.08.2016 в 22:23