Skip to content

Commit

Permalink
update functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kresnasatya committed Dec 27, 2024
1 parent 7adff16 commit e38e13e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions functions/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
export async function onRequest(context) {
try {
// let result = [];
const url = new URL(context.request.url);

let month = context.request.url.searchParams.get('month') || '';
let year = context.request.url.searchParams.get('year') || '';
// Get query parameters using URLSearchParams
const month = url.searchParams.get('month') || '';
const year = url.searchParams.get('year') || '';
let response = new Response(JSON.stringify({ year, month }));

response.headers.set('Cache-Control', 'public, max-age=0, s-maxage=86400');
Expand Down

0 comments on commit e38e13e

Please sign in to comment.