I tried to access api.js
from Routes.js
, but I encountered an issue stating that the function my_function_in_api
is not defined. Here is my code, could you please help me identify where the problem lies:
Routes.js
var val = require('file name')
modules.exports = function(app){
app.get('/test_function',function(req,res){
val.my_function_in_api(req,res)})
api.js
module.exports = (function() {
return {
my_function_in_api: function(req,res) {
// do something}})