Fixed no shortcode

This commit is contained in:
cdricms
2025-02-11 10:21:45 +01:00
parent 2c2be9fdba
commit f84f7fcf8b
2 changed files with 10 additions and 9 deletions

View File

@@ -1,13 +1,14 @@
import IShortcode from "@/interfaces/IShortcode";
import request from "./request";
export default async function getShortcode(code: string): Promise<IShortcode> {
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" || !res.data)
throw new Error("Shortcode doesn't exist.");
if (res.status === "Error") throw new Error("Shortcode doesn't exist.");
return res.data;
return res.data ?? null;
}