{"size": 601, "ext": "js", "max_stars_repo_path": "frontend/src/services/auth.service.js", "max_stars_repo_name": "biowaffeln/puppy-webshop", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "frontend/src/services/auth.service.js", "max_issues_repo_name": "biowaffeln/puppy-webshop", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "frontend/src/services/auth.service.js", "max_forks_repo_name": "biowaffeln/puppy-webshop", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.4642857143, "max_line_length": 69, "alphanum_fraction": 0.622296173}
// Mark

const REACT_APP_BACKEND_URL = process.env.REACT_APP_BACKEND_URL
  ? process.env.REACT_APP_BACKEND_URL
  : 'http://localhost:8000'

async function login(username, password) {
  try {
    const res = await fetch(REACT_APP_BACKEND_URL + '/token-auth/', {
      method: 'POST',
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ username, password })
    })

    return res.status === 400
      ? { errors: 'invalid credentials' }
      : res.json()

  } catch (e) {
    return { errors: 'a server error occured' }
  }
}

export default {
  login
}