Skip to content

Commit

Permalink
Set the dummy title to collection namespace to test the connection
Browse files Browse the repository at this point in the history
  • Loading branch information
mineTomek committed Oct 16, 2023
1 parent 3ad7b67 commit ac25422
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/pages/api/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
res.status(200).json([
{
_id: 'id',
title: { pl: 'Tytuł', en: 'Title' },
content: { pl: 'Zawartość', en: 'Content' },
},
])
try {
const db = await getDb()

// try {
// const db = await getDb()
const collection = db.collection('posts')

// const collection = db.collection('posts')
res.status(200).json([
{
_id: 'id',
title: { pl: 'Tytuł', en: collection.namespace },
content: { pl: 'Zawartość', en: 'Content' },
},
])

// let query = {}
// let query = {}

// const { q } = req.query
// const { q } = req.query

// if (q) {
// try {
// query = JSON.parse(q.toString())
// } catch (error) {
// throw new Error('Invalid query parameter')
// }
// }
// if (q) {
// try {
// query = JSON.parse(q.toString())
// } catch (error) {
// throw new Error('Invalid query parameter')
// }
// }

// const posts = await collection.find(query).toArray()
// const posts = await collection.find(query).toArray()

// res.status(200).json(posts)
// } catch (error) {
// createError((error as Error).message, res, 500, error as Error)
// }
// res.status(200).json(posts)
} catch (error) {
createError((error as Error).message, res, 500, error as Error)
}
}

0 comments on commit ac25422

Please sign in to comment.