Pass a parameter to another JavaScript and run the script

118 views Asked by At

Send a parameter(URL) from another script through recursion to this script.

var express = require('express');
var request = require('request');
var cheerio = require('cheerio');
var mongodb = require('mongodb');
var app     = express();

var MongoClient = mongodb.MongoClient;

// Connection URL. This is where your mongodb server is running.
var murl = 'mongodb://localhost:27017/getData';

url = '';

app.get('/getData', function(req, res){
    firstCall(req,res)
    //console.log("cookie",req.cookies);
})

var firstCall = function(req, res, data){
    console.log("URL: ", url);
    res.send('Check your console!');
}

app.listen('3000')
console.log('Magic happens on port 3000');
module.exports = function(app) {  
  app.get('/getData', function() {});
};

I want this code to act as backbone or logic board. And some other file should be able to trigger this logic board file by adding the URL to this file.

Like we pass parameters to function to call. How do I do it here.

0

There are 0 answers