const axios = require('axios');

async function test() {
  try {
    const loginRes = await axios.post('http://localhost:3001/api/auth/login', {
      email: 'clubs_head@school.com',
      password: 'clubs123'
    });
    const token = loginRes.data.token;
    console.log('Login successful. Token:', token.substring(0, 10) + '...');

    const clubsRes = await axios.get('http://localhost:3001/api/clubs', {
      headers: { Authorization: `Bearer ${token}` }
    });
    console.log('Clubs data retrieved. Count:', clubsRes.data.length);
  } catch (error) {
    console.error('Error:', error.response?.status, error.response?.data || error.message);
  }
}

test();
