得到一个非对象的结果,期望从 create Zapier 得到一个对象?
Got a non-object result, expected an object from create Zapier?
我正在通过 NPM 的 request
模块获取缓冲区,并从该缓冲区中使用另一个模块 pdf-parse
解析 pdf。执行 zap 时出现错误:
Unhandled error: CheckError: Invalid API Response:
- Got a non-object result, expected an object from create ()
下面是我的操作代码
var utils = require('../utils/utils.js')
const pdf = require('pdf-parse');
var isMetaData = false;
var request = require('request').defaults({ encoding: null });
let a = {}
const register = (z, bundle) => {
var url = bundle.inputData.value
getMetaData(url, z).then((a) => {
return a
});
z.console.log("Process started")
};
function getMetaData(url, z) {
z.console.log("In getmetadata");
return new Promise((resolve, reject) => {
request({ url, encoding: null }, (err, resp, buffer) => {
z.console.log("In request response");
pdf(buffer).then(function (data) {
var mdata = data.metadata;
var filtered = {}
for (key in mdata._metadata) {
if (key.match(/^pdfx:blockchain/)) filtered[key] = mdata[key];
}
if (Object.keys(filtered).length === 1) {
isMetaData = true
}
a.isMetaData = isMetaData
resolve(a);
z.console.log("a value set");
});
});
});
}
Zap 的日志:
- - - - - - - - - - - - - - - - - -
== Log
Process started
== Version
0.1.6
== Step
50c914b6-03be-49ee-bd94-469e81811578
== Timestamp
2019-08-18T06:13:49-05:00
- - - - - - - - - - - - - - - - - -
== Log
In getmetadata
== Version
0.1.6
== Step
50c914b6-03be-49ee-bd94-469e81811578
== Timestamp
2019-08-18T06:13:49-05:00
- - - - - - - - - - - - - - - - - -
== Log
Unhandled error: CheckError: Invalid API Response:
- Got a non-object result, expected an object from create ()
What happened:
Executing creates.register.operation.perform with bundle
Invalid API Response:
- Got a non-object result, expected an object from create ()
CheckError: Invalid API Response:
- Got a non-object result, expected an object from create ()
at checkOutput (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/app-middlewares/after/checks.js:37:15)
at Object.collector.then.newOutput (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/middleware.js:80:37)
at bound (domain.js:301:14)
at Object.runBound (domain.js:314:12)
at Object.tryCatcher (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/promise.js:606:10)
at Async._drainQueue (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
== Version
0.1.6
== Step
sdf-03be-49ee-bd94-463481811578
== Timestamp
2019-08-18T06:13:49-05:00
- - - - - - - - - - - - - - - - - -
== Log
In request response
== Version
0.1.6
== Step
ddwrr345e-sad-49ee-bd94-fsd34535
== Timestamp
2019-08-18T06:13:49-05:00
来自 Zapier 平台团队的大卫。
你的 perform
函数需要 return 一个 JS 对象(包裹在 {}
中的东西)。要消除错误,请确保您的承诺 return 是正确的。
最简单的方法如下:
return new Promise((resolve, reject) => {
request({ url, encoding: null }, (err, resp, buffer) => {
// ...
}).then(myPdf => {
return {pdf: myPdf} // <-- an object
})
就是说,我不确定所编写的代码能否使该文件在后续步骤中作为文件对象可用。我会在 https://zapier.github.io/zapier-platform/#stashing-files
查看文档
我正在通过 NPM 的 request
模块获取缓冲区,并从该缓冲区中使用另一个模块 pdf-parse
解析 pdf。执行 zap 时出现错误:
Unhandled error: CheckError: Invalid API Response: - Got a non-object result, expected an object from create ()
下面是我的操作代码
var utils = require('../utils/utils.js')
const pdf = require('pdf-parse');
var isMetaData = false;
var request = require('request').defaults({ encoding: null });
let a = {}
const register = (z, bundle) => {
var url = bundle.inputData.value
getMetaData(url, z).then((a) => {
return a
});
z.console.log("Process started")
};
function getMetaData(url, z) {
z.console.log("In getmetadata");
return new Promise((resolve, reject) => {
request({ url, encoding: null }, (err, resp, buffer) => {
z.console.log("In request response");
pdf(buffer).then(function (data) {
var mdata = data.metadata;
var filtered = {}
for (key in mdata._metadata) {
if (key.match(/^pdfx:blockchain/)) filtered[key] = mdata[key];
}
if (Object.keys(filtered).length === 1) {
isMetaData = true
}
a.isMetaData = isMetaData
resolve(a);
z.console.log("a value set");
});
});
});
}
Zap 的日志:
- - - - - - - - - - - - - - - - - -
== Log
Process started
== Version
0.1.6
== Step
50c914b6-03be-49ee-bd94-469e81811578
== Timestamp
2019-08-18T06:13:49-05:00
- - - - - - - - - - - - - - - - - -
== Log
In getmetadata
== Version
0.1.6
== Step
50c914b6-03be-49ee-bd94-469e81811578
== Timestamp
2019-08-18T06:13:49-05:00
- - - - - - - - - - - - - - - - - -
== Log
Unhandled error: CheckError: Invalid API Response:
- Got a non-object result, expected an object from create ()
What happened:
Executing creates.register.operation.perform with bundle
Invalid API Response:
- Got a non-object result, expected an object from create ()
CheckError: Invalid API Response:
- Got a non-object result, expected an object from create ()
at checkOutput (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/app-middlewares/after/checks.js:37:15)
at Object.collector.then.newOutput (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/middleware.js:80:37)
at bound (domain.js:301:14)
at Object.runBound (domain.js:314:12)
at Object.tryCatcher (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromiseCtx (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/promise.js:606:10)
at Async._drainQueue (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (:censored:9:d1ba0cf2aa:/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
== Version
0.1.6
== Step
sdf-03be-49ee-bd94-463481811578
== Timestamp
2019-08-18T06:13:49-05:00
- - - - - - - - - - - - - - - - - -
== Log
In request response
== Version
0.1.6
== Step
ddwrr345e-sad-49ee-bd94-fsd34535
== Timestamp
2019-08-18T06:13:49-05:00
来自 Zapier 平台团队的大卫。
你的 perform
函数需要 return 一个 JS 对象(包裹在 {}
中的东西)。要消除错误,请确保您的承诺 return 是正确的。
最简单的方法如下:
return new Promise((resolve, reject) => {
request({ url, encoding: null }, (err, resp, buffer) => {
// ...
}).then(myPdf => {
return {pdf: myPdf} // <-- an object
})
就是说,我不确定所编写的代码能否使该文件在后续步骤中作为文件对象可用。我会在 https://zapier.github.io/zapier-platform/#stashing-files
查看文档