Tuesday, 25 April 2017

NodeJS - My method doesn't execute

inside my file ./functions/login_registration_functions.js

I have the following code

var methods = {
    check_if_not_null: function (item_to_be_checked, item_to_store_the_checked_item) {
        if(item_to_be_checked != null){
            item_to_store_the_checked_item = item_to_be_checked;
        }
}
};

module.exports = methods;

and I am calling it inside my routes.js file

var log_reg_funcs = require('./functions/login_registration_functions.js');

and I am calling the method inside my put call

log_reg_funcs.check_if_not_null(req.body.title, request.title);

but it doesn't work. when I replace the above code with below:

if(req.body.title != null){
            request.title = req.body.title;
        }

it works fine

why am I missing here?



via Behrouz Riahi

No comments:

Post a Comment