本文整理汇总了TypeScript中cote.Requester.send方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Requester.send方法的具体用法?TypeScript Requester.send怎么用?TypeScript Requester.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cote.Requester
的用法示例。
在下文中一共展示了Requester.send方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: mongooseRequester
mongooseRequester() {
const userRequester = new cote.Requester({ name: 'User Requester' });
userRequester
.send({ type: 'find', payload: { username: 'foo' } })
.then(user => console.log(user))
.then(() => process.exit());
}
示例2: requester
requester() {
const randomRequester = new cote.Requester({
name: 'Random Requester',
namespace: 'rnd',
key: 'a certain key',
requests: ['randomRequest']
});
const req = {
type: 'randomRequest',
payload: {
val: Math.floor(Math.random() * 10)
}
};
randomRequester.send(req)
.then(console.log)
.catch(console.log)
.then(() => process.exit());
}
示例3: requesterCallback
requesterCallback() {
const randomRequester = new cote.Requester({
name: 'Random Requester',
namespace: 'rnd',
key: 'a certain key',
requests: ['randomRequest']
});
const req = {
type: 'randomRequest',
payload: {
val: Math.floor(Math.random() * 10)
}
};
randomRequester.send(req, res => {
console.log(res);
process.exit();
});
}
示例4:
responder.on('convert', (req: any) => {
return conversionRequester.send(req); // proxy the request
});