23 lines
587 B
TypeScript
23 lines
587 B
TypeScript
import { ConnectedAircraft, ConnectedDispatcher } from "@repo/db";
|
|
import axios from "axios";
|
|
|
|
export const serverApi = axios.create({
|
|
baseURL: process.env.NEXT_PUBLIC_DISPATCH_SERVER_URL,
|
|
timeout: 10000,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
});
|
|
|
|
export const getConenctedUsers = async (): Promise<
|
|
(ConnectedDispatcher | ConnectedAircraft)[]
|
|
> => {
|
|
const res = await serverApi.get<(ConnectedDispatcher | ConnectedAircraft)[]>(
|
|
"/status/connected-users",
|
|
);
|
|
if (res.status !== 200) {
|
|
throw new Error("Failed to fetch connected users");
|
|
}
|
|
return res.data;
|
|
};
|