Files
NSG_PORTAL_V2/server/models/author.ts
T

32 lines
823 B
TypeScript
Raw Normal View History

2024-05-31 13:57:40 +07:00
import { utils } from "~/utils/utilities";
import Base from "./base";
import { H3Event } from "h3";
export type Author = {
id:number;
siteId:number;
userId:number;
title:string
code:string;
description?:string;
thumbnail?:string;
feature?:string;
type?:number;
}
export const fetchByCode = async (event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
2024-07-15 21:02:22 +07:00
const { authorCode }: any = getQuery(event);
const query = getQuery(event)
2024-05-31 13:57:40 +07:00
const { items }: any = await $fetch(`${apiUrl}/cms/author/code:${authorCode}`, {
method: 'GET',
2024-07-15 21:02:22 +07:00
headers: new Headers({
site: getSite(query.site).toString(),
}),
2024-05-31 13:57:40 +07:00
})
return items[0]
} catch (error) {
handleError(error)
}
}