Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Node.js add get route - building a restful api
SUBMITTED BY:
Guest
DATE:
Aug. 4, 2013, 5:48 p.m.
FORMAT:
Text only
SIZE:
263 Bytes
Raw
Download
Tweet
HITS:
1116
Go to comments
Report
app.get('/quote/:id', function(req, res) {
if(quotes.length <= req.params.id || req.params.id < 0) {
res.statusCode = 404;
return res.send('Error 404: No quote found');
}
var q = quotes[req.params.id];
res.json(q);
});
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus