43 lines
904 B
TypeScript
43 lines
904 B
TypeScript
import { defineEventHandler, getQuery } from 'h3'
|
||
|
||
export default defineEventHandler(async (event) => {
|
||
try {
|
||
const { search } = getQuery(event)
|
||
const apiUrl = process.env.VITE_MY_API_BASE_URL!
|
||
|
||
return [
|
||
{
|
||
userId: 1,
|
||
id: 1,
|
||
title: 'pizda',
|
||
body: 'jopa',
|
||
},
|
||
{
|
||
userId: 1,
|
||
id: 1,
|
||
title: 'pizda',
|
||
body: 'jopa',
|
||
},
|
||
{
|
||
userId: 1,
|
||
id: 1,
|
||
title: 'pizda',
|
||
body: 'jopa',
|
||
},
|
||
]
|
||
|
||
// return await $fetch<Posts>(`${apiUrl}/posts?title_like=${search}`, {
|
||
// headers: {
|
||
// 'Content-Type': 'application/json',
|
||
// 'Accept-Language': 'ru-RU',
|
||
// },
|
||
// })
|
||
}
|
||
catch (error) {
|
||
return sendError(event, createError({
|
||
statusCode: 500,
|
||
statusMessage: `Не удалось получить посты: ${error}`,
|
||
}))
|
||
}
|
||
})
|