NodeJS Axios: The "listener" argument must be of type Function
I have simple function that uses axios to make an API call. It is called multiple times and after few I get the same error on every of them:
Trace: TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type object at checkListener (events.js:77:11) at TLSSocket.once (events.js:326:3) at Object.connect (_tls_wrap.js:1425:13) at Agent.createConnection (https.js:125:22) at Agent.createSocket (_http_agent.js:242:26) at Agent.addRequest (_http_agent.js:201:10) at new ClientRequest (_http_client.js:276:16) at Object.request (https.js:309:10) at RedirectableRequest._performRequest (webpack:///./node_modules/follow-redirects/index.js?:169:24) at new RedirectableRequest (webpack:///./node_modules/follow-redirects/index.js?:66:8) { code: 'ERR_INVALID_ARG_TYPE' }
I am using Vue in my app for frontend, but this function is called from NodeJS backend.
Axios instance:
this.axios = axios.create({ withCredentials: true, responseType: 'json' });
Axios call:
await this.axios({ url: this.url, method: 'POST', headers: this.headers, responseType: 'json', withCredentials: true, params: { input: 'test', method: method }, data: callData });
Thank you.
It is caused by electron. I had to use electron net library to do the requests instead of axios.
Thanks to @Daniel_Knights for suggestions.