Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8059565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:42:41+00:00 2026-06-05T09:42:41+00:00

I use node.js with the express framework and I have figured out how the

  • 0

I use node.js with the express framework and I have figured out how the routing works.

app.get('/save',webcalender.save);

I have a webcalender file with this function:

exports.save = function(req, res){
res.send(req.query["headline"]);};

But how would I built a different function and use it in there:

exports.test = function() { console.log("test"); }

I have tried:

exports.save = function(req, res){
    test(); or webcalender.test or also test = webcalender.test(); and then test;
res.send(req.query["headline"]);};

thanks for you help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:42:43+00:00Added an answer on June 5, 2026 at 9:42 am

    This question is a bit unclear.

    I assume save function is defined in some webcalendar.js and imported with

    var webcalendar = require('./webcalendar.js');
    

    Ill break the answer now in two scenarios.

    Assuming test function is the same webcalendar.js

    You can then do something like

    var test = function() {console.log("test");}
    exports.test = test;
    

    Or in one line

    var test = module.exports.test = function() {console.log("test");}
    

    And then to use test in the same module simply call test(); like you did.

    In case if test is defined in another module

    Lets say in test.js then in order to use it in webcalendar.js module you have to require it like this:

    var test = require('./test.js').test;
    exports.save = function(req, res){
        test();
    res.send(req.query["headline"]);};
    

    or simply

    exports.save = function(req, res){
        require('./test.js').test();
    res.send(req.query["headline"]);};
    

    This should cover most of the cases, if its not please clarify your question since as I said earlier its unclear.

    Also I suggest you to familiarize your self with nodejs module to understand why, what and when you need to export, since its not clear from you question why are you exporting the test function (in case if its used only in webcalendar.js module).
    Here is another good resource to nodejs require

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic Node.js app that I am trying to get off the
I'm using Node.js together with Express framework and i18n module . So I use
Is it safe to do something like this in Node.js/Express.js? // use Object.create(null) so
after install Express.js, I wrote this on node: var express = require('express'), app =express.createServer();
In my app (node / express / redis), I use some code to update
I have been trying to figure out how to integrate a node.js app into
I got this simple script ulizting express framework and node-mysql. Basically, the code listens
I use node.js - Express. I have a page (index.html) and html div (id
I'm using node.js and the less compiler middleware: app.configure(function() { // ... app.use(express.compiler({ src:
I've written a REST API on the express framework for node.js that works for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.