0
我在執行下面我試圖從ember-simple-auth-token
獲得令牌和一個網址,用來與ActionCable連接使用:如何從ember-simple-auth-token獲取令牌以使用Websocket?
...
export default Route.extend({
store: service(),
currentUser: service(),
session: service(),
cable: service(),
setupConsumer: on('init', function() {
let token = this.get('session.data.authenticated.jwt');
let consumer = this.get('cable')
.createConsumer(`wss://api.${config.APP.host}/cable?token=${token}`);
let channelMixin = Mixin.create({
received(data) {
this.get('store').pushPayload(data);
}
});
consumer.subscriptions.create({
channel: 'ChatroomsChannel'
}, channelMixin);
}),
...
});
這種方法只適用於第一次請求。我需要將這個存儲在cookie中?謝謝。