我正在设置一个羽毛-客户端使用的ES6类,我想导入在我的反应-Redux应用程序的行动。
我已经建立了一个REST使用可怕的羽毛脚手架。
不幸的是,我在浏览器中发现了一个错误,它正在毁掉我的一天。我做错了什么?
Uncaught:_client2.default.hooks不是函数
有人能帮我吗?为什么hooks (以及rest)在这里没有定义?包裹似乎安装得很好..。
以下是个好主意吗?
// src/middleware/api.js
import hooks from 'feathers-hooks'
import feathers from 'feathers/client'
import rest from 'feathers-rest/client'
class API {
constructor() {
const connection = process.env.FEATHERS_API_URL
this.app = feathers()
.configure(feathers.hooks())
.configure(rest(connection).fetch(fetch))
.configure(feathers.authentication({
type: 'local',
storage: window.localStorage,
}))
}
}是不是有些软件包不兼容?
"feathers": "^2.0.3",
"feathers-authentication": "^0.7.12",
"feathers-client": "^1.8.0",
"feathers-configuration": "^0.3.3",
"feathers-errors": "^2.5.0",
"feathers-hooks": "^1.7.1",
"feathers-rest": "^1.5.2",
"feathers-sequelize": "^1.4.0"我想知道的另一件事是,我们总是需要为rest函数提供路径吗?默认情况下可以使用配置文件中使用的路径吗?如果我的客户端和服务器端代码都在同一个项目中,给它一个路径感觉有点奇怪.
发布于 2016-12-20 00:55:10
@feathersjs/client是一个包,包含一组羽毛标准模块(如auth、rest、socketio客户端),可以直接在浏览器中使用(参见这里的文件)。
看起来,您正在尝试使用模块加载器这里有记载,因此,而不是使用预捆绑包(其中所有内容都在feathers.名称空间中,如feathers.hooks、feathers.authentication等)。您只能导入所需的模块并配置它们:
// src/middleware/api.js
import feathers from '@feathersjs/feathers'
import rest from '@feathersjs/rest-client'
import authentication from '@feathersjs/authentication-client'
class API {
constructor() {
const connection = process.env.FEATHERS_API_URL
this.app = feathers()
.configure(rest(connection).fetch(fetch))
.configure(authentication({
type: 'local',
storage: window.localStorage,
}))
}
}如果rest在同一个域上运行,则不需要基本url。默认情况下,它是一个空字符串。
https://stackoverflow.com/questions/41226678
复制相似问题