md-y/mangadex-full-api

Issues on cacheLogin

Closed this issue · 0 comments

Hi I'm using your npm package with electron and when I try to use api.agent.cachelogin, when the given file where the sessions are stored does not exist, it does fine, no error, but when the file already exists, it throws this error:

Uncaught (in promise) TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type object
    at checkListener (events.js:63)
    at ClientRequest.once (events.js:304)
    at new ClientRequest (_http_client.js:178)
    at request (https.js:309)
    at Object.get (https.js:313)
    at C:\Users\xx\Documents\..\node_modules\mangadex-full-api\src\util.js:27
    at new Promise (<anonymous>)
    at Object.getHTTPS (C:\Users\xx\Documents\..\node_modules\mangadex-full-api\src\util.js:11)
    at C:\Users\xx\Documents\..\node_modules\mangadex-full-api\src\util.js:83
    at new Promise (<anonymous>)

My code:

function login(user, pass, rememberMe){
  if(!fs.existsSync(`${process.env.APPDATA}\\MyngaDex`)){
    fs.mkdirSync(`${process.env.APPDATA}\\MyngaDex\\Sessions`, {recursive: true}, err => {errToast.fire(`Error: ${err}`)})
    console.log("created")
  }
  
    api.agent.cacheLogin(`${process.env.APPDATA}\\MyngaDex\\Sessions\\session.txt`, user, pass, rememberMe)
}

This code is called from button in html file
(my NodeJS version is 10.16.0)