в таком коде
app.get('/basket', function(req, res) {
// Connect to MySQL database.
var connection = getMySQLConnection();
// Do the query to get data.
var query='SELECT `id`,`prod`,`name`,`photo`,`price`,`sale`,`baskethash`,`remote_adr`,`quantity` FROM `basket` WHERE `remote_adr`="::ffff:127.0.0.1"';
connection.query(query,
function(err, results, fields) {
console.log(err);
var smartphone=[];
var smartphoneList=[];
var allprice;
var a;
var b;
for(var i=0;i<results.length;i++) {
// Create the object to save the data.
b=results[i].price-results[i].price*results[i].sale/100;
a=b*results[i].quantity;
var smart = {
'id': results[i].id,
'prod': results[i].prod,
'name': results[i].name,
'photo': results[i].photo,
'sale': results[i].sale,
'price': results[i].price,
'tsale': b,
'vsego':a,
'quantity': results[i].quantity,
};
allprice +=smart.vsego;
smartphone.push(smart);
}
var addrss=request.headers['x-forwarded-for'];
var smartphoneList={
'allprice':allprice,
'len':results.length,
"ip":addrss,
}
res.render('basket', {"smartphoneList": smartphoneList,"smartphone": smartphone,});
});
connection.end();
// Close MySQL connection
});
пишет
C:\xampp\htdocs\mysite.local\node_modules\mysql\li b\protocol\Parser.js:437
throw err; // Rethrow non-MySQL errors
^
ReferenceError: request is not defined
at Query.<anonymous> (C:\xampp\htdocs\mysite.local\app.js:223:24)
\app.js:223:24 это строка где определяется addrss