Skip to content
Snippets Groups Projects
api.js 752 B
Newer Older
Marc Taylor's avatar
Marc Taylor committed
// src/utils/api.js
import axios from 'axios';

const API_BASE_URL = 'http://127.0.0.1:8000';
axios.defaults.xsrfCookieName = 'csrftoken';
axios.defaults.xsrfHeaderName = 'X-CSRFToken';
axios.defaults.withCredentials = true;


export const login = async (username, password) => {
  try {
    const response = await axios.post('http://127.0.0.1:8000/themeApp/login/', {
      username: username,
      password: password
    }, {
      headers: {
        'Content-Type': 'application/json'
      },
      withCredentials: true  // Include cookies in the request
    });
    console.log('Login success:', response.data);
    return response.status
  } catch (error) {
    console.error('Login error:', error);
  }
}

// Other API calls can be added here