[英]TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string
I'm working on an NPM package to make a command handler for Discord.我正在研究 NPM package 来为 Discord 创建一个命令处理程序。 I get the following error:
我收到以下错误:
(node:9400) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received undefined.
he error says that is in line:他的错误说这是一致的:
switch (_f.label) {
I tried all but I dont have a solution我尝试了所有但我没有解决方案
The value in the switch
statement should be of the same type as the values in the case
statements. switch
语句中的值应与case
语句中的值具有相同的类型。
In your sample, the value in switch
is a string
, and the cases are number
s.在您的示例中,
switch
中的值是string
,而 case 是number
。
Make them all of the same type:使它们都具有相同的类型:
switch(parseInt(label)) {
or或者
case "0":
case "1":
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.