目前我有2条路线。制造商模型与Manufacturer_tabs模型具有一对多关系。我在Sequelize和PostgreSQL中使用ExpressJS。当我尝试获取Manufacturer_tabs数据时,在邮递员中收到404错误。
app.js
var manufacturers = require('./routes/manufacturers');
var manufacturer_tabs = require('./routes/manufacturer_tabs');
app.use('/manufacturers', manufacturers);
app.use('/manufacturers/:manufacturer_id/manufacturer-tabs', manufacturer_tabs);
manufacturer_tabs.js
var models = require('../models');
var express = require('express');
var router = express.Router();
/* Get Manufacturer Tabs List */
router.get('/', function(req, res) {
var manufacturer_id = req.params.manufacturer_id;
models.ManufacturerTab.findAll().
then(function(manufacturers) {
res.status(200).json(manufacturers);
}, function(error) {
res.status(500).send(error);
});
});
module.exports = router;