WebClient files.upload失败,无法读取未定义的属性“名称”

时间:2018-06-28 14:26:49

标签: slack slack-api

当尝试在服务器上使用files.upload API上传文件时,我正在将要上传的文件转换为多部分表单数据时遇到以下错误:

TypeError: Cannot read property 'name' of undefined 
    at FormData._getContentDisposition (/app/node_modules/form-data/lib/form_data.js:226:40) 
    at FormData._multiPartHeader (/app/node_modules/form-data/lib/form_data.js:177:33) 
    at FormData.append (/app/node_modules/form-data/lib/form_data.js:70:21) 
    at flattened.reduce (/app/node_modules/@slack/client/dist/WebClient.js:459:26) 
    at Array.reduce (<anonymous>) 
    at WebClient.serializeApiCallOptions (/app/node_modules/@slack/client/dist/WebClient.js:438:30) 
    at WebClient.<anonymous> (/app/node_modules/@slack/client/dist/WebClient.js:342:38) 
    at Generator.next (<anonymous>) 
    at /app/node_modules/@slack/client/dist/WebClient.js:7:71
    at new Promise (<anonymous>)

它在本地对我有效,但是在我的服务器上,相同的代码给出了以上响应。有谁知道是什么原因造成的?

1 个答案:

答案 0 :(得分:1)

如果初始化WebClient的令牌为undefined,则会出现此看似无关的错误消息。

我举起了an issue in Slack's Github来追踪这一点。