first commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { useToNumber, useToString } from '@vueuse/core'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const query = getQuery(event)
|
||||
const limit = useToNumber(useToString(query.limit).value).value || 5
|
||||
const search = useToString(query.search)
|
||||
|
||||
try {
|
||||
const countries = await prisma.addressCountries.findMany({
|
||||
// where: {
|
||||
// Name: {
|
||||
// startsWith: search.value,
|
||||
// mode: 'insensitive',
|
||||
// },
|
||||
// },
|
||||
// take: limit,
|
||||
})
|
||||
return countries.map((c) => {
|
||||
return {
|
||||
Code: c.Code,
|
||||
Name: c.Name,
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
// Return error if fetching users fails
|
||||
return {
|
||||
status: 500,
|
||||
body: { message: 'Failed to fetch countries' },
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user