从MongoDB获取数据时出错

昨天我遇到了MongoDB的exception行为。 所以..我将国家和语言与他们的代码存储在集合中,当客户端应用程序需要这些数据 – 它发送“获取”请求来获取数据。 它同时发生

function init() { helperService .getCountries() .then(success) .catch(commonService.handleError); function success(res) { self.countries = res.data; } } function init() { helperService .getLanguages() .then(success) .catch(commonService.handleError); function success(res) { self.languages = res.data; } } 

在这里我发送请求来获取angular度组件$ onInit中的数据

后端代码看起来很简单:

 var country = require('countryModel'); var language = require('languageModel'); function getCountries(req, res, next) { return country .find({}) .then(success) .catch(next); function success(data) { res.json(data); } } function getLanguages(req, res, next) { return language .find({}) .then(success) .catch(next); function success(data) { res.json(data); } } 

本地所有工作如预期。 但是,在Linux服务器上部署应用程序后,我经常看到错误404“无法GET / API /语言”和“无法GET / api /国家”。 有时我得到的数据,但更多的时候我得到了一个错误或上面的这两个错误。 有谁能告诉我什么是错的?

在我看来,你注册路线有问题。 请检查它