Files
cal.diy/packages/ee/lib/core/checkPremiumUsername.ts
T
00c9df7602 There is lot of hardcoding links in application (#3130)
* There is lot of hardcoding links in application

* Apply suggestions from code review

Co-authored-by: Joe Au-Yeung <[email protected]>

Co-authored-by: gitstart <[email protected]>
Co-authored-by: Omar López <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
2022-07-01 11:19:52 -06:00

26 lines
653 B
TypeScript

import slugify from "@calcom/lib/slugify";
import { WEBSITE_URL } from "@calcom/lib/constants";
export type ResponseUsernameApi = {
available: boolean;
premium: boolean;
message?: string;
suggestion?: string;
};
export async function checkPremiumUsername(_username: string): Promise<ResponseUsernameApi> {
const username = slugify(_username);
const response = await fetch(`${ WEBSITE_URL }/api/username`, {
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ username }),
method: "POST",
mode: "cors",
});
const json = await response.json();
return json;
}