-
-
Save sendbird-community/9967c26934269204660e1b3009f0c70d to your computer and use it in GitHub Desktop.
Helper methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HTTPError extends Error { | |
constructor({status, response}) { | |
super(`HTTP request failed: ${status} ${statusText}`); | |
this.response = response; | |
} | |
} | |
const makePostCall = async (url, body) => { | |
const result = await $request.post(url, {headers, body}) | |
return JSON.parse(result.response) | |
} | |
const fetchNewSendBirdSessionToken = async (userId) => { | |
const url = `https://api-${APP_ID}.sendbird.com/v3/users/${userId}/token` | |
const body = JSON.stringify({expires_at: Date.now() + 1000 * 60 * 60}); | |
return makePostCall(url, body) | |
} | |
const createNewSendbirdUser = async (userId) => { | |
const url = `https://api-${APP_ID}.sendbird.com/v3/users` | |
const body = JSON.stringify({user_id: userId, nickname: "", profile_url: ""}); | |
return makePostCall(url, body) | |
} | |
const createNewSendbirdGroupCallRoom = async (type = 'small_room_for_video') => { | |
const url = `https://api-${APP_ID}.calls.sendbird.com/v1/rooms` | |
const body = JSON.stringify({type}); | |
return makePostCall(url, body) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment