Skip to content

Commit

Permalink
feat: fetch title and content from request (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
aahna-ashina committed May 23, 2022
1 parent 0a5ec99 commit d7ed197
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions server/pages/api/pushNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,26 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
// Push notification to all the passes
console.log('Pushing notification...')

const title = 'title...' // TODO
const content = 'content...' // TODO
const { title } = req.query
console.log(`title: "${title}"`)
if (!title || (String(title).trim().length == 0)) {
res.status(400).json({ error: 'Missing/empty parameter: title' })
return
}

const { content } = req.query
console.log(`content: "${content}"`)
if (!content || (String(content).trim().length == 0)) {
res.status(400).json({ error: 'Missing/empty parameter: content' })
return
}

// Remove leading/trailing whitespace
const trimmedTitle = String(title).trim()
const trimmedContent = String(content).trim()

// Push notification
// TODO

res.status(response.statusCode).json({ text: '// TODO' })
}
Expand Down

0 comments on commit d7ed197

Please sign in to comment.