import IShortcode from "@/interfaces/IShortcode";
import request from "./request";

export default async function getShortcode(
	code: string,
): Promise<IShortcode | null> {
	const res = await request<IShortcode>(`/shortcodes/${code}`, {
		method: "GET",
		requiresAuth: false,
	});
	if (res.status === "Error") throw new Error("Shortcode doesn't exist.");

	return res.data ?? null;
}
