我有使用axios进行API调用的简单函数。它被多次调用,几次后我都得到相同的错误:
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'
}
我在应用程序中使用Vue作为前端,但是从NodeJS后端调用了此函数。
Axios实例:
this.axios = axios.create({
withCredentials: true,
responseType: 'json'
});
Axios电话:
await this.axios({
url: this.url,
method: 'POST',
headers: this.headers,
responseType: 'json',
withCredentials: true,
params: {
input: 'test',
method: method
},
data: callData
});
谢谢。
答案 0 :(得分:0)
它是由电子引起的。我不得不使用电子网络库来执行请求,而不是使用axios。
感谢@Daniel_Knights的建议。