Procházet zdrojové kódy

[feature] handle 401 logic in axios

create_edit_user
jason.lam před 4 měsíci
rodič
revize
6db6664894
1 změnil soubory, kde provedl 7 přidání a 3 odebrání
  1. +7
    -3
      src/components/ItemsSearch/ItemsSearch.tsx

+ 7
- 3
src/components/ItemsSearch/ItemsSearch.tsx Zobrazit soubor

@@ -85,16 +85,20 @@ const ItemsSearch: React.FC<Props> = ({ items }) => {
}, [filterObj, pagingController.pageNum, pagingController.pageSize]);

const refetchData = async (filterObj: SearchQuery) => {
// Make sure the API endpoint is correct

const authHeader = axiosInstance.defaults.headers['Authorization'];
if (!authHeader) {
return; // Exit the function if the token is not set
}

const params ={
pageNum: pagingController.pageNum,
pageSize: pagingController.pageSize,
...filterObj,
}

try {
console.log("[debug] axiosInstance", axiosInstance)
const response = await axiosInstance.get<ItemsResult[]>(`${NEXT_PUBLIC_API_URL}/items/getRecordByPage`, { params });
console.log("[debug] resposne", response)
setFilteredItems(response.data.records);
setPagingController({
...pagingController,


Načítá se…
Zrušit
Uložit