FPSMS-frontend
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 

29 строки
749 B

  1. "use client";
  2. import { NEXT_PUBLIC_API_URL } from "@/config/api";
  3. import { QcItemInfo } from "./index";
  4. export const fetchQcItemsByCategoryId = async (categoryId: number): Promise<QcItemInfo[]> => {
  5. const token = localStorage.getItem("accessToken");
  6. const response = await fetch(`${NEXT_PUBLIC_API_URL}/qcCategories/${categoryId}/items`, {
  7. method: "GET",
  8. headers: {
  9. "Content-Type": "application/json",
  10. ...(token && { Authorization: `Bearer ${token}` }),
  11. },
  12. });
  13. if (!response.ok) {
  14. if (response.status === 401) {
  15. throw new Error("Unauthorized: Please log in again");
  16. }
  17. throw new Error(`Failed to fetch QC items: ${response.status} ${response.statusText}`);
  18. }
  19. return response.json();
  20. };