2016-07-02 52 views
1

昨天我遇到了MongoDB的异常行为。 所以..我将国家和语言的代码存储在集合中,当客户端应用程序需要这些数据时 - 它会发送“获取”请求来获取数据。如预期从MongoDB获取数据时出错

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); 
    } 
} 

本地所有作品:它同时发生

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; 
      } 
     } 

在这里,我发送请求获得角分量$ OnInit的数据

后端代码看起来非常简单。但在Linux服务器上部署应用程序后,我经常看到错误404'无法GET/api /语言'和'无法GET/api /国家'。有时我得到的数据,但更多时候我得到一个错误或上面的这两个错误。 有谁能告诉我什么是错的?

回答

1

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