3

Hello I have this function in app.js

    const LOLTrackingSystem = setInterval(async () => {
    await LOLUserData.LOLUserData(3, async (result) => { // [Step (2)]
      await summonerStats.summonerStats (result , async (result) => { // [Step (3)]
        await addPointsToUser.addPointsToUser(result) // [Step (4)] Final
      })
    })
  }, 2000);

working fine but I want to put the function in separate file and export it and use it in app.js here is what I have done

LOLTracking.js

    //=============================================================================
// LOL Ranked Games Wins Tracking System
//=============================================================================
const LOLUserData = require('../leagueOfLegends/getUserData')
const summonerStats = require('../leagueOfLegends/getSummonerStats')
const addPointsToUser = require('../gizmo/addPoints')

const LOLTrackingSystem = setInterval(async () => {
    await LOLUserData.LOLUserData(3, async (result) => { // [Step (2)]
      await summonerStats.summonerStats (result , async (result) => { // [Step (3)]
        await addPointsToUser.addPointsToUser(result) // [Step (4)] Final
      })
    })
  }, 2000);
exports.LOLTrackingSystem = LOLTrackingSystem

but now when i require it and use it in my app.js like this

 const LOLTrackingSystem = require('./src/methods/onlineGamesTracking/LOLTracking')

const run = async () => {

await LOLTrackingSystem.LOLTrackingSystem()

}

run()

I get an error saying

TypeError: LOLTrackingSystem.LOLTrackingSystem is not a function

what am I doing wrong?

1 Answer 1

2

Be careful, you have set the LOLTrackingSystem with an interval, which return an id and not a function it’s a misunderstanding.

So when you call it in your app it’s not a function.

What you can do is

LOLTrackingSystem = () => setInterval(..., 2000)
exports.LOLTrackingSystem = LOLTrackingSystem
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect. Thank you very much :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.