Answer the question
In order to leave comments, you need to log in
Error in Express routing?
I'm trying to make a simple server on node.js (4.2.6) + express (4.14.0)
Which, in response to a request with the version parameter, returns the value of this parameter.
If you open the url " localhost:8080/api/v10 ", for some reason in I get an error: "Cannot GET /api/v10"
What am I doing wrong?
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json());
var router = express.Router();
router.get('/api:version', function (req, res) {
res.send(req.params.version);
});
app.use('/', router);
var listener = app.listen(8080, function(){
console.log('******* Express server listening on port ' + listener.address().port);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question