1

Yesterday I faced with unusual behavior for MongoDB. So.. I store countries and languages with their codes in collections and when client side application need this data - it sends 'get' request to get data. It happens simultaneously

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

Here I send request to get data in angular component $onInit

Backend code looks pretty simple:

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

Locally all works as expected. But after deploying application on linux server I often see error 404 'Cannot GET /api/language' and 'Cannot GET /api/country'. Sometimes I got data but more often I got one error or this two errors above. Could anybody give me idea what is wrong?

1 Answer 1

1

It seems to me that you have problems with registering routes. Check it please

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.