Skip to content

Commit

Permalink
fix: URL on fetch requests for channels (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipecabaco authored Apr 6, 2024
1 parent d4c95ae commit ce01817
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/RealtimeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export default class RealtimeClient {
* @param name Channel name to create
*/
createChannel(name: string): Promise<string> {
const url = `${this.httpEndpoint}/channels`
const url = `${this.httpEndpoint}/api/channels/`
return this.fetch(url, {
method: 'POST',
headers: {
Expand All @@ -350,7 +350,7 @@ export default class RealtimeClient {
* @param name Channel name to delete.
*/
deleteChannel(name: string): Promise<boolean> {
const url = `${this.httpEndpoint}/channels/${name}`
const url = `${this.httpEndpoint}/api/channels/${name}`
return this.fetch(url, {
method: 'DELETE',
headers: {
Expand All @@ -374,7 +374,7 @@ export default class RealtimeClient {
* @param new_name New channel name.
*/
updateChannel(name: string, new_name: string): Promise<string> {
const url = `${this.httpEndpoint}/channels/${name}`
const url = `${this.httpEndpoint}/api/channels/${name}`
return this.fetch(url, {
method: 'PATCH',
headers: {
Expand All @@ -395,7 +395,9 @@ export default class RealtimeClient {
* Lists private channels
*/
listChannels(): Promise<string[]> {
const url = `${this.httpEndpoint}/channels`
const url = `${this.httpEndpoint}/api/channels/`
console.log('!!!')
console.log(url)
return this.fetch(url, {
method: 'GET',
headers: {
Expand Down
8 changes: 4 additions & 4 deletions test/socket_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ describe('createChannel', () => {
const jwt = 'jwt'
fetch = (url, opts) => {
if (
url == `http://localhost:4000/channels` &&
url == `http://localhost:4000/api/channels/` &&
opts.method == 'POST' &&
opts.headers['Content-Type'] == 'application/json' &&
opts.headers['Authorization'] == `Bearer ${jwt}` &&
Expand Down Expand Up @@ -906,7 +906,7 @@ describe('deleteChannel', () => {
const jwt = 'jwt'
fetch = (url, opts) => {
if (
url == `http://localhost:4000/channels/${name}` &&
url == `http://localhost:4000/api/channels/${name}` &&
opts.method == 'DELETE' &&
opts.headers['Authorization'] == `Bearer ${jwt}` &&
opts.headers['apikey'] == apikey
Expand Down Expand Up @@ -940,7 +940,7 @@ describe('updateChannel', () => {
const jwt = 'jwt'
fetch = (url, opts) => {
if (
url == `http://localhost:4000/channels/${name}` &&
url == `http://localhost:4000/api/channels/${name}` &&
opts.method == 'PATCH' &&
opts.headers['Authorization'] == `Bearer ${jwt}` &&
opts.headers['apikey'] == apikey
Expand Down Expand Up @@ -975,7 +975,7 @@ describe('listChannels', () => {
const jwt = 'jwt'
fetch = (url, opts) => {
if (
url == `http://localhost:4000/channels` &&
url == `http://localhost:4000/api/channels/` &&
opts.method == 'GET' &&
opts.headers['Authorization'] == `Bearer ${jwt}` &&
opts.headers['apikey'] == apikey
Expand Down

0 comments on commit ce01817

Please sign in to comment.