Fixed download category

This commit is contained in:
2023-03-18 20:32:03 +00:00
parent b86c1ba8f3
commit c15178da22
3 changed files with 50 additions and 4 deletions

View File

@@ -29,7 +29,7 @@ const SignsPage: React.FC = () => {
};
const handleDownloadData = async () => {
downloadSigns().then((blob: Blob) => {
downloadSigns(id!).then((blob: Blob) => {
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;

View File

@@ -51,11 +51,11 @@ const getSign = async (id: number) => {
return response.json();
};
const downloadSigns = async () => {
const downloadSigns = async (category: string) => {
// get access token from local storage
const token = localStorage.getItem('accessToken');
// make request to download signs
const response = await fetch(`${process.env.REACT_APP_API_URL}/signs/download/all`, {
const response = await fetch(`${process.env.REACT_APP_API_URL}/categories/${category}/download`, {
headers: {
Authorization: `Bearer ${token}`
}