Skip to content

Instantly share code, notes, and snippets.

@banagale
Last active May 12, 2021 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banagale/d632e1b37dd892b49fd1e33187dee51f to your computer and use it in GitHub Desktop.
Save banagale/d632e1b37dd892b49fd1e33187dee51f to your computer and use it in GitHub Desktop.
Example custom hook for retrieving an OpenVidu session token, implemented using React Query
import Cookies from "js-cookie";
import { wvApiUrl } from "../../routes";
const fetchUrl = wvApiUrl.ovToken();
export async function useCreateSessionToken(bodyData) {
const response = await fetch(fetchUrl, {
method: 'POST',
body: JSON.stringify(bodyData),
headers: {
"Content-type": "application/json",
"X-CSRFToken": Cookies.get('csrftoken')
}
});
return await response.json();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment