imApi.ts 578 B

123456789101112131415161718192021222324
  1. import { v4 as uuidv4 } from "uuid";
  2. import { getChatUrl } from "@/config";
  3. import createAxiosInstance from "@/utils/request";
  4. import { getChatToken } from "@/utils/storage";
  5. const request = createAxiosInstance(getChatUrl());
  6. export const getRtcConnectData = async (room: string, identity: string) => {
  7. const token = (await getChatToken()) as string;
  8. return request.post<{ serverUrl: string; token: string }>(
  9. "/user/rtc/get_token",
  10. {
  11. room,
  12. identity,
  13. },
  14. {
  15. headers: {
  16. token,
  17. operationID: uuidv4(),
  18. },
  19. },
  20. );
  21. };