feat: input virtual add header request api

This commit is contained in:
Firman Syah 2026-05-19 15:11:06 +07:00
parent fc3b752b97
commit bbd3f8d252
2 changed files with 9 additions and 12 deletions

View File

@ -8,16 +8,6 @@ const createClient = (baseURL, withBaseFormat = false) => {
headers: { 'Content-Type': 'application/json', Accept: 'application/json' } headers: { 'Content-Type': 'application/json', Accept: 'application/json' }
}); });
client.interceptors.request.use((config) => {
const token = typeof window !== 'undefined' ? localStorage.getItem('token') : null;
if (token) {
config.headers = config.headers ?? {};
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
if (withBaseFormat) { if (withBaseFormat) {
client.interceptors.response.use( client.interceptors.response.use(
(response) => (response) =>

View File

@ -33,6 +33,7 @@ export default function ListVirtual({
helperText, helperText,
filter, filter,
isApiGo = false, isApiGo = false,
headersRequest,
}) { }) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
@ -72,7 +73,10 @@ export default function ListVirtual({
url, url,
payload.build(), payload.build(),
{}, {},
{ isApiGo } {
isApiGo,
headers: headersRequest
}
); );
const incomingData = res.data || []; const incomingData = res.data || [];
@ -125,7 +129,10 @@ export default function ListVirtual({
url, url,
payload.build(), payload.build(),
{}, {},
{ isApiGo } {
isApiGo,
headers: headersRequest
}
); );
const data = res.data?.[0]; const data = res.data?.[0];