feat: Update assets and improve code comments across multiple components
- Updated favicon and various image assets. - Enhanced comments. - Adjusted styles and functionality in several components for improved user experience. - Updated package-lock.json to reflect dependency updates.
This commit is contained in:
12
utils/api.ts
12
utils/api.ts
@@ -4,17 +4,17 @@ import * as SecureStore from 'expo-secure-store';
|
||||
const API_BASE_URL = process.env.EXPO_PUBLIC_API_URL;
|
||||
export const KEY_TOKEN = 'auth_key';
|
||||
|
||||
// Crea un'istanza di axios
|
||||
// Create an Axios instance with default configuration
|
||||
const api = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
timeout: 10000, // 10 secondi timeout
|
||||
timeout: 10000, // 10 seconds timeout
|
||||
});
|
||||
|
||||
// Interceptor: Aggiunge il token a OGNI richiesta se esiste
|
||||
// Interceptor: Adds the token to EVERY request if it exists
|
||||
api.interceptors.request.use(
|
||||
async (config) => {
|
||||
const token = await SecureStore.getItemAsync(KEY_TOKEN);
|
||||
@@ -29,7 +29,7 @@ api.interceptors.request.use(
|
||||
}
|
||||
);
|
||||
|
||||
// Interceptor: Gestione errori globale (es. token scaduto)
|
||||
// Interceptor: Global error handling (e.g., expired token)
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
async (error) => {
|
||||
@@ -38,9 +38,9 @@ api.interceptors.response.use(
|
||||
if (error.response) {
|
||||
console.error('[API ERROR]', error.response.status, error.response.data);
|
||||
|
||||
// Se riceviamo 401 (Unauthorized), potremmo voler fare il logout forzato
|
||||
// If we receive 401 (Unauthorized), we might want to force logout
|
||||
if (error.response.status === 401) {
|
||||
// TODO: Qui potresti emettere un evento per disconnettere l'utente
|
||||
// TODO: Here you can add logic to redirect to login screen if needed
|
||||
await SecureStore.deleteItemAsync(KEY_TOKEN);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user