API端点响应问题和服务器路由
我尝试了注释部分(以实现对“ / api”端点的响应。) 这里是userRootAPI.js文件
const { usersAPI } = require('./users');
module.exports = (database) => {
// TODO: you need to implement the response to the '/api' endpoint.
router.use('/user', usersAPI);
return router;
};
另一个rootAPI文件
const apiRouter = require('./components/userRootAPI');
const app = express();
app.use(bodyParser.json());
app.use('/api', apiRouter);
// TODO: you need to implement server routing!!
module.exports.app = app;
这是server.js文件
const { app } = require('./rootAPI');
const PORT = process.env.PORT || 3002;
app.listen(PORT, () => {
console.info(`Server is listening on PORT : ${PORT}`);
});
我需要'/ api'响应和服务器路由