function logoutUser() {
    const url = '/rest-auth/logout/'
    const options = {
        method: 'POST',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json',
          'X-CSRFToken': getCookie('csrftoken')
        },
        body: JSON.stringify({
        })
      }
    fetch(url, options)
      .then(resp => resp.json())
      .then(json => {
          if(json.detail === 'Successfully logged out.'){
              window.localStorage.removeItem('key')
              window.sessionStorage.removeItem('key')
              window.location.href = '/login'
          }else{
              console.error('A problem ha ocurred!!')
          }
      })
}
// Function to logout an authenticated user
Function to logout an authenticated user
Function to logout an authenticated user
function logoutUser() {
    const url = '/rest-auth/logout/'
    const options = {
        method: 'POST',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json',
          'X-CSRFToken': getCookie('csrftoken')
        },
        body: JSON.stringify({
        })
      }
    fetch(url, options)
      .then(resp => resp.json())
      .then(json => {
          if(json.detail === 'Successfully logged out.'){
              window.localStorage.removeItem('key')
              window.sessionStorage.removeItem('key')
              window.location.href = '/login'
          }else{
              console.error('A problem ha ocurred!!')
          }
      })
}
function logoutUser ( ) { const url = '/rest-auth/logout/' const options = { method : 'POST' , headers : { 'Accept' : 'application/json' , 'Content-Type' : 'application/json' , 'X-CSRFToken' : getCookie ( 'csrftoken' ) } , body : JSON . stringify ( { } ) } fetch ( url , options ) . then ( resp => resp . json ( ) ) . then ( json => { if ( json . detail === 'Successfully logged out.' ) { window . localStorage . removeItem ( 'key' ) window . sessionStorage . removeItem ( 'key' ) window . location . href = '/login' } else { console . error ( 'A problem ha ocurred!!' ) } } ) }
Function to logout an authenticated user
Function to logout an authenticated user