未使用 ember-data 时缺少 ember-simple-auth 授权 header
Missing ember-simple-auth authorization header when not using ember-data
我刚刚升级我的应用程序以使用 ember-simple-auth 的 jj-abrams 分支(即将成为 1.0)。
当我使用 ember 数据时,它工作得很好,但对于一条路线,我使用 Ember.$.getJSON 直接从服务器检索图表数据。
在这种情况下,请求中缺少授权 header,我猜这是因为它没有使用应用程序适配器(因此绕过了 authorizer: 'authorizer:devise'
)?
有没有办法手动添加此 header,或者提出此请求的更好方法?
当然你可以只包含会话然后你应该可以访问凭据并使用你需要的任何东西将它们添加到你的路由器(我假设它在你的路由器上使用 AuthenticatedRouteMixin。
或为您的控制器添加:
session: Ember.inject.service('session')
然后你可以做一个 get:
this.get('session')
并检查该对象以在其中找到您需要的内容,我相信这应该会让您更轻松地 运行 而无需使用 Ember-Data。
我刚刚升级我的应用程序以使用 ember-simple-auth 的 jj-abrams 分支(即将成为 1.0)。
当我使用 ember 数据时,它工作得很好,但对于一条路线,我使用 Ember.$.getJSON 直接从服务器检索图表数据。
在这种情况下,请求中缺少授权 header,我猜这是因为它没有使用应用程序适配器(因此绕过了 authorizer: 'authorizer:devise'
)?
有没有办法手动添加此 header,或者提出此请求的更好方法?
当然你可以只包含会话然后你应该可以访问凭据并使用你需要的任何东西将它们添加到你的路由器(我假设它在你的路由器上使用 AuthenticatedRouteMixin。
或为您的控制器添加:
session: Ember.inject.service('session')
然后你可以做一个 get:
this.get('session')
并检查该对象以在其中找到您需要的内容,我相信这应该会让您更轻松地 运行 而无需使用 Ember-Data。