Se agrego datastage

This commit is contained in:
2025-08-14 16:35:09 -06:00
parent 7948deeed5
commit e86547d10d
8 changed files with 579 additions and 10 deletions

View File

@@ -86,14 +86,17 @@ const refreshToken = async () => {
// Función principal para hacer peticiones con manejo automático de tokens
export const fetchWithAuth = async (url, options = {}) => {
// Obtener el token actual
let token = localStorage.getItem('access');
// Configurar headers por defecto
const defaultHeaders = {
'Content-Type': 'application/json',
...(token && { 'Authorization': `Bearer ${token}` })
};
let defaultHeaders = {};
if (token) defaultHeaders['Authorization'] = `Bearer ${token}`;
// Solo poner Content-Type si no es GET o si hay body
if ((options.method && options.method.toUpperCase() !== 'GET') || options.body) {
defaultHeaders['Content-Type'] = 'application/json';
}
// Combinar headers
const finalOptions = {