Function not defined after requiring module

0

I was creating two separate modules from my main code to keep it organized and easy to understand. So I created a new folder and in it 2 files, index.js and search.js

  • The function of search.js is to retain a function.
  • The function of index.js is to retain all functions that would not need to be delivered as parameters for gsearch , as well as export the function itself from the search.js module to the main file outside of that folder.

The base code looks something like this:

  

index.js

const { gsearch } = require("./search.js")

function preEmbed(){
    // Some code
}

function toSend(){
    //Some code
}
module.exports = {gsearch,preEmbed,toSend}
  

search.js

const {preEmbed} = require("./index.js")
const {toSend}  = require("./index.js")

function gsearch(){
    //Some code
    var embed = preEmbed()
}
module.exports = gsearch

After trying to run the gsearch function, the following code is logged in the console:

The same happens with the function toSend

  

Pre-order is not a function

The complete code can be found at this stem if necessary:

  

link

    
asked by anonymous 09.08.2018 / 02:56

0 answers