Fetching & Displaying Data

What is the recommended approach for handling authentication tokens in API requests?
const api = {
  async request(url, options = {}) {
    const token = localStorage.getItem('authToken');
    const headers = new Headers(options.headers || {});
    
    if (token) {
      headers.set('Authorization', `Bearer ${token}`);
    }
    
    const response = await fetch(url, { ...options, headers });
    
    if (response.status === 401) {
      // Token expired or invalid
      localStorage.removeItem('authToken');
      redirectToLogin();
      return;
    }
    
    return response;
  }
};
Next Question (14/20)