Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ab-smith committed Dec 7, 2024
1 parent cfd4e08 commit 394e8ed
Showing 1 changed file with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@

import { BASE_API_URL } from '$lib/utils/constants';

import { error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
export const GET: RequestHandler = async ({ fetch, params }) => {
const URLModel = 'compliance-assessments';
const endpoint = `${BASE_API_URL}/${URLModel}/${params.id}/word_report/`;
const URLModel = 'compliance-assessments';
const endpoint = `${BASE_API_URL}/${URLModel}/${params.id}/word_report/`;

const res = await fetch(endpoint);
if (!res.ok) {
error(400, 'Error fetching the Word file');
}
const res = await fetch(endpoint);
if (!res.ok) {
error(400, 'Error fetching the Word file');
}

const fileName = `audit-report-${new Date().toISOString()}.docx`;
const fileName = `audit-report-${new Date().toISOString()}.docx`;

return new Response(await res.blob(), {
headers: {
'Content-Type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'Content-Disposition': `attachment; filename="${fileName}"`
}
});
return new Response(await res.blob(), {
headers: {
'Content-Type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'Content-Disposition': `attachment; filename="${fileName}"`
}
});
};

0 comments on commit 394e8ed

Please sign in to comment.