mean mean 2 express:get route()只返回" /"路线

时间:2016-12-19 16:59:12

标签: angular express mean-stack

您好我正在创建一个Angular2均值堆栈应用。我认为没有正确调用第二条路由的调用。网络响应是html而不是JSON

import express = require('express');
import path = require('path');

import ContactRoutes = require('../routes/ContactRoutes');
import EstimateRoutes = require('../routes/EstimateRoutes');
var app = express();

class Routes {
    get routes() {
        app.use("/", new ContactRoutes().routes);
        app.use("/estimates", new EstimateRoutes().routes);
        return app;
    }
}
export = Routes;

1 个答案:

答案 0 :(得分:0)

解决:我找到的解决方案是在两个用途中添加根“/”。

app.use("/", new ContactRoutes().routes);
app.use("/", new EstimateRoutes().routes);

不确定路线是如何确定的但是有效。