Files

36 lines
1.0 KiB
TypeScript
Raw Permalink Normal View History

2024-06-06 13:29:22 +07:00
import { H3Event } from 'h3';
import Base from './base'
2024-07-16 22:54:15 +07:00
import { useCookie } from 'nuxt/app';
2024-06-06 13:29:22 +07:00
export type PollOption = {
id?: number; // Mã định danh
siteId?: number; // Mã hệ thống
pollId?: number; // Mã bình chọn
title?: string; // Tiêu đề
thumbnail?: string; // Ảnh đại diện
description?: string; // Mô tả
type?: number; // Phân loại
order?: number; // Sắp xếp
status?: number; // Trạng thái
2024-06-17 11:48:00 +07:00
responseCount?: number //số lượng response của option
}
2024-06-06 13:29:22 +07:00
export const fetchByPollId = async (event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
const { pollId }: any = getQuery(event)
2024-07-17 10:35:35 +07:00
const query = getQuery(event)
const { items }: PollOption[] | any = await $fetch(`${apiUrl}/cms/poll-option/poll:${pollId}`, {
2024-06-06 13:29:22 +07:00
method: 'GET',
headers: {
2024-07-17 10:35:35 +07:00
site: getSite(query.site).toString()
2024-07-16 22:54:15 +07:00
},
2024-06-06 13:29:22 +07:00
})
return items
} catch (error) {
handleError(error);
}
}