Skip to content

Commit 66ddf24

Browse files
committed
catch error
1 parent 958f87c commit 66ddf24

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

pages/api/confirm.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default async function handle(req, res) {
1414
subject: `${req.body.name}! You are registered for the hackathon`,
1515
html: `<h2>Hello ${req.body.name}!</h2>
1616
<p>You have successfully registered for the Open Components Hackathon.</p>
17-
<p>From <b>February 13 to 17</b>, the first part, Lernathon, will take place.<br/>
17+
<p>From <b>February 13 to 17</b>, the first part, Learnathon, will take place.<br/>
1818
Don't forget to add a reminder to your calendar.</p>
1919
<p>Also join our <a href="https://discord.gg/2zjFVgaw4E" target="_blank">discord</a>.</p>
2020
<br/>

pages/api/generate.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import path from 'path'
22
import { promises as fs } from 'fs'
33

44
export default async function handler(req, res) {
5-
const jsonDirectory = path.join(process.cwd())
6-
const data = await require('react-google-forms-hooks').googleFormsToJson(
7-
'https://docs.google.com/forms/d/e/' +
8-
(process.env.GOOGLE_FORM_ID ??
9-
'1FAIpQLSdma-rdJELwPGL-Iw7x28h3nZbvCaiFAABpz9B_17kuemSbWg') +
10-
'/viewform'
11-
)
12-
await fs.writeFile(jsonDirectory + '/GoogleForm.json', JSON.stringify(data))
5+
try {
6+
const jsonDirectory = path.join(process.cwd())
7+
const data = await require('react-google-forms-hooks').googleFormsToJson(
8+
'https://docs.google.com/forms/d/e/' +
9+
(process.env.GOOGLE_FORM_ID ??
10+
'1FAIpQLSdma-rdJELwPGL-Iw7x28h3nZbvCaiFAABpz9B_17kuemSbWg') +
11+
'/viewform'
12+
)
13+
await fs.writeFile(jsonDirectory + '/GoogleForm.json', JSON.stringify(data))
14+
} catch (error) {
15+
return res.status(500).json({ error })
16+
}
1317
//Return the content of the data file in json format
14-
res.status(200).json({ status: 'success' })
18+
return res.status(200).json({ status: 'success' })
1519
}

0 commit comments

Comments
 (0)