【发布时间】:2018-06-14 02:33:49
【问题描述】:
我做了跟随:
feathers g app # with socket and rest
feathers g service # todos & NeDB
npm start
和简单的客户端。我从文档中复制代码 https://docs.feathersjs.com/api/client/socketio.
const feathers = require('@feathersjs/feathers');
const socketio = require('@feathersjs/socketio-client');
const io = require('socket.io-client');
const socket = io('http://localhost:3030');
const app = feathers();
app.configure(socketio(socket));
app.service('todos')
.on('created', message => console.log('New message created', message));
app.service('todos').find().then(r => {
console.log(r)
}).catch(e => console.log('error',e))
app.service('todos').create({
title: 'A message from a REST client'
});
这个客户端代码让我遇到 find() 和 create() 方法的超时错误
但如果我通过 CURL 发出 POST 请求,我在控制台中有 onCreated 消息
为什么我在 create() 和 find() 调用时出错?
更新:
我制作了 git repo 以便于重现这个问题 https://github.com/tolyanor/feathersjs-error
更新2:
我更改自动生成的文件 src/app.js 就像在羽毛示例聊天应用程序 https://github.com/feathersjs/feathers-chat/blob/master/src/app.js 中一样
现在我可以在客户端调用服务方法创建,但不能接收 onCreated 消息。所以,这段代码
app.service('/todos')
.on('created', message => console.log('New todos created', message));
从不打电话
【问题讨论】:
标签: feathersjs