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 /國家'。有時我得到的數據,但更多時候我得到一個錯誤或上面的這兩個錯誤。 有誰能告訴我什麼是錯的?