mysql - How to pass URL param from Angular to NodeJS(Express) to use it in SQL query? -


i have table , click on record(row) opens new view new url rowid clicked record (localhost/1). want pass rowid param url express , use in sql query. can making request server this

$http.post('/load/:rowid',{'row_id': rowid})        .success(function(response){             //handle ok response         })        .error(function(response){             //habndle error         }) 

and use rowid in express search in database:

app.get('/load', function(req, res) {  var querystring = 'select * table row_id = rowid'; connection.query(querystring, function (error, results) {     if(error) {         throw error;     }     else {         // got result: render         res.end(json.stringify(results));         console.log(res);     } }); 

});

and @ end data rowid show on frontend?

$http.get('http://localhost/load').success(function (data) {             data.foreach( function( row, index ) {                 $scope.push(data);             });         }) 


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -