我正在尝试 MDN Express 教程第 2 部分中的自我挑战部分。创建 Express 项目后,他们会提出以下问题:
在
/routes/users.js
中创建一条新路线,该路线将在 URL /users/cool/ 处显示文本“You're so Cool”。通过运行服务器并访问来测试它
http://localhost:3000/users/cool/
在您的浏览器中
我已经尝试过,但不断收到 404 错误
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res, next) {
res.send('respond with a resource');
});
// this was for the challenge youself portion, to create something that appears at /users/cool...but it wont work
router.get('/cool', function(req, res, next) {
res.send('You are so cool!');
});
module.exports = router;