Przeglądaj źródła

[feature] handle 401 logic in axios

create_edit_user
jason.lam 4 miesięcy temu
rodzic
commit
6db6664894
1 zmienionych plików z 7 dodań i 3 usunięć
  1. +7
    -3
      src/components/ItemsSearch/ItemsSearch.tsx

+ 7
- 3
src/components/ItemsSearch/ItemsSearch.tsx Wyświetl plik

@@ -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,


Ładowanie…
Anuluj
Zapisz