fetching
This commit is contained in:
@@ -91,10 +91,12 @@ export const fetchWithAuth = async (url, options = {}) => {
|
||||
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 = {
|
||||
|
||||
Reference in New Issue
Block a user