|
15 | 15 | import { CategoryTranslations, Response } from '../interfaces'; |
16 | 16 |
|
17 | 17 | export const fetchCategoryTranslations = async (categoryId: string): Promise<CategoryTranslations> => { |
18 | | - try { |
19 | | - const response = await fetch(`./api/category/translations/${categoryId}`, { |
20 | | - method: 'GET', |
21 | | - cache: 'no-cache', |
22 | | - headers: { |
23 | | - 'Content-Type': 'application/json', |
24 | | - }, |
25 | | - redirect: 'follow', |
26 | | - referrerPolicy: 'no-referrer', |
27 | | - }); |
| 18 | + const response = await fetch(`./api/category/translations/${categoryId}`, { |
| 19 | + method: 'GET', |
| 20 | + cache: 'no-cache', |
| 21 | + headers: { |
| 22 | + 'Content-Type': 'application/json', |
| 23 | + }, |
| 24 | + redirect: 'follow', |
| 25 | + referrerPolicy: 'no-referrer', |
| 26 | + }); |
28 | 27 |
|
29 | | - return await response.json(); |
30 | | - } catch (error) { |
31 | | - throw error; |
32 | | - } |
| 28 | + return await response.json(); |
33 | 29 | }; |
34 | 30 |
|
35 | 31 | export const deleteCategory = async ( |
36 | 32 | categoryId: string, |
37 | 33 | language: string, |
38 | 34 | csrfToken: string |
39 | 35 | ): Promise<Response | undefined> => { |
40 | | - try { |
41 | | - const response = await fetch(`./api/category/delete`, { |
42 | | - method: 'DELETE', |
43 | | - cache: 'no-cache', |
44 | | - headers: { |
45 | | - 'Content-Type': 'application/json', |
46 | | - }, |
47 | | - body: JSON.stringify({ |
48 | | - categoryId: categoryId, |
49 | | - language: language, |
50 | | - csrfToken: csrfToken, |
51 | | - }), |
52 | | - redirect: 'follow', |
53 | | - referrerPolicy: 'no-referrer', |
54 | | - }); |
| 36 | + const response = await fetch(`./api/category/delete`, { |
| 37 | + method: 'DELETE', |
| 38 | + cache: 'no-cache', |
| 39 | + headers: { |
| 40 | + 'Content-Type': 'application/json', |
| 41 | + }, |
| 42 | + body: JSON.stringify({ |
| 43 | + categoryId: categoryId, |
| 44 | + language: language, |
| 45 | + csrfToken: csrfToken, |
| 46 | + }), |
| 47 | + redirect: 'follow', |
| 48 | + referrerPolicy: 'no-referrer', |
| 49 | + }); |
55 | 50 |
|
56 | | - return await response.json(); |
57 | | - } catch (error) { |
58 | | - throw error; |
59 | | - } |
| 51 | + return await response.json(); |
60 | 52 | }; |
61 | 53 |
|
62 | 54 | export const setCategoryTree = async ( |
63 | | - categoryTree: any, |
| 55 | + categoryTree: unknown, |
64 | 56 | categoryId: string, |
65 | 57 | csrfToken: string |
66 | 58 | ): Promise<Response | undefined> => { |
67 | | - try { |
68 | | - const response = await fetch('./api/category/update-order', { |
69 | | - method: 'POST', |
70 | | - cache: 'no-cache', |
71 | | - headers: { |
72 | | - 'Content-Type': 'application/json', |
73 | | - }, |
74 | | - body: JSON.stringify({ |
75 | | - categoryTree: categoryTree, |
76 | | - categoryId: categoryId, |
77 | | - csrfToken: csrfToken, |
78 | | - }), |
79 | | - redirect: 'follow', |
80 | | - referrerPolicy: 'no-referrer', |
81 | | - }); |
| 59 | + const response = await fetch('./api/category/update-order', { |
| 60 | + method: 'POST', |
| 61 | + cache: 'no-cache', |
| 62 | + headers: { |
| 63 | + 'Content-Type': 'application/json', |
| 64 | + }, |
| 65 | + body: JSON.stringify({ |
| 66 | + categoryTree: categoryTree, |
| 67 | + categoryId: categoryId, |
| 68 | + csrfToken: csrfToken, |
| 69 | + }), |
| 70 | + redirect: 'follow', |
| 71 | + referrerPolicy: 'no-referrer', |
| 72 | + }); |
82 | 73 |
|
83 | | - return await response.json(); |
84 | | - } catch (error) { |
85 | | - throw error; |
86 | | - } |
| 74 | + return await response.json(); |
87 | 75 | }; |
0 commit comments