Skip to content

Commit

Permalink
Add log_backend api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
matt8707 committed Apr 18, 2024
1 parent dca1b0f commit 0548470
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/routes/_api/log_backend/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { RequestHandler } from './$types';

// // Example

// async function logBackend(message: string, data: any) {
// try {
// const response = await fetch(`${base}/_api/server_log`, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// },
// body: JSON.stringify({ message, data })
// });
// const result = await response.json();
// console.log(result.status);
// } catch (err) {
// console.error('Failed to log message to backend:', err);
// }
// }

export const POST: RequestHandler = async ({ request }) => {
const { message, data } = await request.json();

console.log(message, data);

return new Response(JSON.stringify({ status: 'Logged' }), {
headers: {
'Content-Type': 'application/json'
},
status: 200
});
};

0 comments on commit 0548470

Please sign in to comment.