alipay / alipay-sdk-nodejs-all

支付宝开放平台 Alipay SDK for Node.js
https://docs.open.alipay.com/54/103419/
Other
406 stars 62 forks source link

调用接口alipay.open.agent.facetoface.sign报错source.on is not a function #97

Closed zhangyj1998 closed 1 year ago

zhangyj1998 commented 1 year ago

接口文档地址https://opendocs.alipay.com/isv/04ejak?pathHash=20d91b56 因为里面需要传图片,所以采用form的形式上传,其中shop_address字段为object,就是因为这个字段,导致报错,请问如何解决

TypeError: source.on is not a function", " at Function.DelayedStream.create (/Users/zhangyijun/workCode/server/node_modules/delayed-stream/lib/delayed_stream.js:33:10)", " at FormData.CombinedStream.append (/Users/zhangyijun/workCode/server/node_modules/combined-stream/lib/combined_stream.js:44:37)", " at FormData.append (/Users/zhangyijun/workCode/server/node_modules/request/node_modules/form-data/lib/form_data.js:74:3)", " at appendFormValue (/Users/zhangyijun/workCode/server/node_modules/request/request.js:326:21)", " at Request.init (/Users/zhangyijun/workCode/server/node_modules/request/request.js:337:11)", " at new Request (/Users/zhangyijun/workCode/server/node_modules/request/request.js:127:8)", " at request (/Users/zhangyijun/workCode/server/node_modules/request/index.js:53:10)", " at Function.post (/Users/zhangyijun/workCode/server/node_modules/request/index.js:61:12)", " at /Users/zhangyijun/workCode/server/node_modules/alipay-sdk/lib/alipay.ts:226:15", " at new Promise ()

fengmk2 commented 1 year ago

@troyeagle 看看,应该是 bug

zhangyj1998 commented 1 year ago

我尝试将node_modules/alipay-sdk/lib/form.js修改之后就可以了,但是不确定对其他接口是否有影响

addField(fieldName, fieldValue) { if (isJSON(fieldValue)) { // 当 fieldValue 为 json 字符串时,解析出 json // this.fields.push({ name: fieldName, value: JSON.parse(fieldValue) }); this.fields.push({ name: fieldName, value:fieldValue }); } else { this.fields.push({ name: fieldName, value: fieldValue }); } }

troyeagle commented 1 year ago

应该和 #93 是同一个问题,底层确实没针对 object 类型的字段做序列化,应当都要 stringify 。即刻修复

troyeagle commented 1 year ago

fixed on v3.3.1