Skip to content

Commit

Permalink
fix: channel.send via rest api (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukhammadali authored Jan 11, 2024
1 parent 3c5c3db commit 9116776
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/RealtimeChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export default class RealtimeChannel {
const options = {
method: 'POST',
headers: {
apikey: this.socket.accessToken ?? '',
apikey: this.socket.apiKey ?? '',
'Content-Type': 'application/json',
},
body: JSON.stringify({
Expand Down
6 changes: 5 additions & 1 deletion src/RealtimeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const NATIVE_WEBSOCKET_AVAILABLE = typeof WebSocket !== 'undefined'

export default class RealtimeClient {
accessToken: string | null = null
apiKey: string | null = null
channels: RealtimeChannel[] = []
endPoint: string = ''
headers?: { [key: string]: string } = DEFAULT_HEADERS
Expand Down Expand Up @@ -124,7 +125,10 @@ export default class RealtimeClient {
this.heartbeatIntervalMs = options.heartbeatIntervalMs

const accessToken = options?.params?.apikey
if (accessToken) this.accessToken = accessToken
if (accessToken) {
this.accessToken = accessToken
this.apiKey = accessToken
}

this.reconnectAfterMs = options?.reconnectAfterMs
? options.reconnectAfterMs
Expand Down

0 comments on commit 9116776

Please sign in to comment.