16
rated 0 times
[
23]
[
7]
/ answers: 1 / hits: 82406
/ 11 Years ago, thu, november 21, 2013, 12:00:00
I am using express and Node.js. When I run the function below to get the value of an URL,
Json.stringify(url)
gives me the error.
ReferenceError: Json is not defined.
app.get(/id, function (req, res, next) {
var id = req.param(id);
connection.query('SELECT `url` FROM dynamic_url where id =' + req.param(id), function (error, rows, fields) {
if (err) {
return next(err);
}
var url;
if (rows.length === 0) {
url = 'URL not available in database'
} else {
url = rows[0].url;
}
var i = Json.stringify(url);
res.redirect(i);
});
});
More From » node.js