[英]How do I alert multiple results of a callback from an arrow function?
I can alert a single result from a callback but don't know how to structure my code for multiple results. 我可以从回调中提醒单个结果,但不知道如何为多个结果构建我的代码。
I've returned a string from my extendscript file with success but when I try to return an object or an array with multiple strings it errors 我成功地从我的extendscript文件返回了一个字符串,但是当我尝试返回一个对象或一个包含多个字符串的数组时,它会出错
// THIS WORKS
//// extendscript.jsx
return 'success';
//// main.js
evalExtendscript(`parseProfileDCLVOD(${JSON.stringify(form)})`)
.then(result => alert(result)) // alerts 'success'
.catch(error => alert(error))
//---------------------------------------------------
// THIS DOESN'T WORK
//// extendscript.jsx
var result = {
variant: 'success',
message: 'Export successful'
}
return result;
//// main.js
evalExtendscript(`parseProfileDCLVOD(${JSON.stringify(form)})`)
.then(result => {
alert(result.variant)
alert(result.message)
})
.catch(error => alert(error))
I don't think I'm structuring my code for the result correctly. 我不认为我正在为结果正确构建我的代码。
I found the error. 我发现了错误。 It was actually a problem in the extendscript.jsx.
这实际上是extendscript.jsx中的一个问题。 It was supposed to be:
应该是:
var result = {
variant: 'success',
message: 'Export successful'
}
return JSON.stringify(result);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.