Skip to content

Commit

Permalink
fix: double-quotes and missing filename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
wscourge committed Jul 29, 2023
1 parent 4f017df commit 30fcccd
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions examples/example-nextjs13.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
// app/api/calendar/route.ts

import icalendar from 'ical-generator'
import moment from 'moment'
import icalendar from "ical-generator"
import moment from "moment"

export async function GET(req) {
if (req.method !== 'GET') {
return new Response('Method Not Allowed', {
headers: { Allow: 'GET' },
if (req.method !== "GET") {
return new Response("Method Not Allowed", {
headers: { Allow: "GET" },
status: 405,
})
}
}

try {
const filename = "calendar.ics"

try {
const calendar = icalendar({
prodId: '//superman-industries.com//ical-generator//EN',
prodId: "//superman-industries.com//ical-generator//EN",
events: [
{
start: moment(),
end: moment().add(1, 'hour'),
summary: 'Example Event',
description: 'It works ;)',
url: 'https://example.com'
end: moment().add(1, "hour"),
summary: "Example Event",
description: "It works ;)",
url: "https://example.com"
}
]
});

return new Response(calendar.toString(), {
headers: {
"Content-Type": 'text/calendar; charset=utf-8',
"Content-Type": "text/calendar; charset=utf-8",
"Content-Disposition": `attachment; filename="${filename}"`,
},
status: 200,
})
} catch (err) {
} catch (err) {
console.error(err)
return new Response(JSON.stringify(err), { status: 500 })
}
}
}

0 comments on commit 30fcccd

Please sign in to comment.