| 1 |
function getCookie (name) { |
| 2 |
let cookieValue = null |
| 3 |
if (document.cookie && document.cookie !== '') { |
| 4 |
const cookies = document.cookie.split(';') |
| 5 |
for (let i = 0; i < cookies.length; i++) { |
| 6 |
const cookie = cookies[i].trim() |
| 7 |
// Does this cookie string begin with the name we want? |
| 8 |
if (cookie.substring(0, name.length + 1) === (name + '=')) { |
| 9 |
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)) |
| 10 |
break |
| 11 |
} |
| 12 |
} |
| 13 |
} |
| 14 |
return cookieValue |
| 15 |
} |
| 16 |
export function getCSRFToken () { |
| 17 |
return getCookie('csrftoken') |
| 18 |
} |