ddpclient과 when.js을 사용하려고합니다. 필자가 작성한 코드는 게시물 하단에 있습니다. 이것을 사용하려고하면 다음 오류가 발생합니다. 이 오류를 해결하는 방법에 대한 아이디어가 있습니까? 약속을 사용하는 또 다른 DDPclient을 알고 있지만 추가 약속 라이브러리를 추가하지는 않습니다. 아래약속과 함께 DDPClient를 어떻게 사용합니까?
Potentially unhandled rejection TypeError: Object #<Object> has no method '_nextId'
at DDPClient.call (/Source/proj/node_modules/ddp/lib/ddp-client.js:329:17)
at /Source/tellme/updater/node_modules/when/node.js:89:7
at tryCatchReject (/Source/proj/node_modules/when/lib/makePromise.js:790:14)
at FulfilledHandler.when (/Source/tellme/updater/node_modules/when/lib/makePromise.js:621:9)
at ContinuationTask.run (/Source/tellme/updater/node_modules/when/lib/makePromise.js:741:24)
at Scheduler._drain (/Source/proj/node_modules/when/lib/scheduler.js:56:14)
at Scheduler.drain (/Source/proj/node_modules/when/lib/scheduler.js:21:9)
at process._tickCallback (node.js:419:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
코드 :
"use strict";
var when = require('when'),
node = require('when/node'),
DDPClient = require('ddp');
var ddpclient = new DDPClient({
host: "localhost",
port: 3000
});
var ddpconnect = node.lift(ddpclient.connect);
var ddpcall = node.lift(ddpclient.call);
//var ddpConnectPromise = node.lift(ddpclient.connect);
var obj = {"name": "john","age":25};
when(ddpconnect).then
(ddpcall("processObj", obj)).
catch(function (error) {
console.log(error);
}).
done();
편집 : 다음은 가까이 날 잡으려고 나타납니다,하지만 난 발생 [형식 오류를 : processObj가있는 방법 '의 addListener'이없는 오브젝트] 오류가 발생했습니다. 당신이 bluebird를 사용 괜찮다면
"use strict";
var when = require('when'),
node = require('when/node'),
DDPClient = require('ddp');
var ddpConnectPromise = node.liftAll(DDPClient);
var ddpclient = new ddpConnectPromise({
host: "localhost",
port: 3000
});
var obj = {"name": "john","age":25};
when(ddpclient.connect).then(function (ddpclient) {
ddpclient.call("processObj", sampleJSON);
}).
catch(function (error) {
console.log(error);
}).
done();
[이 잘 작동하지 않습니다 프로토 타입 객체에'liftAll'를 사용하는 것 같습니다.] (https://github.com/cujojs/when/issues/294) – user3374348