File tree 1 file changed +24
-18
lines changed
1 file changed +24
-18
lines changed Original file line number Diff line number Diff line change @@ -140,25 +140,31 @@ export class Websocket {
140
140
this . options . auth . headers [ 'Authorization' ] = 'Bearer ' + this . options . bearerToken ;
141
141
}
142
142
143
- axios . post ( this . options . authEndpoint , {
144
- socket_id : this . getSocketId ( ) ,
145
- channel_name : channel . name ,
146
- } , {
147
- headers : this . options . auth . headers || { }
148
- } ) . then ( ( response : AxiosResponse ) => {
149
- console . log ( `Subscribing to channels ${ channel . name } ` )
150
-
151
- this . send ( {
152
- event : 'subscribe' ,
153
- data : {
154
- channel : channel . name ,
155
- ... response . data
156
- } ,
143
+ fetch ( this . options . authEndpoint , {
144
+ method : 'POST' ,
145
+ headers : {
146
+ ...this . options . auth . headers ,
147
+ 'Content-Type' : 'application/json'
148
+ } ,
149
+ body : JSON . stringify ( {
150
+ socket_id : this . getSocketId ( ) ,
151
+ channel_name : channel . name ,
157
152
} )
158
- } ) . catch ( ( error ) => {
159
- console . log ( `Auth request for channel ${ channel . name } failed` )
160
- console . error ( error )
161
- } )
153
+ } ) . then ( ( response ) => response . json ( ) )
154
+ . then ( ( data ) => {
155
+ console . log ( `Subscribing to channels ${ channel . name } ` )
156
+
157
+ this . send ( {
158
+ event : 'subscribe' ,
159
+ data : {
160
+ channel : channel . name ,
161
+ ... data
162
+ } ,
163
+ } )
164
+ } ) . catch ( ( error ) => {
165
+ console . log ( `Auth request for channel ${ channel . name } failed` )
166
+ console . error ( error )
167
+ } ) ;
162
168
} else {
163
169
console . log ( `Subscribing to channels ${ channel . name } ` )
164
170
You can’t perform that action at this time.
0 commit comments