Fixed no shortcode
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user