cookieforreact


class CookieConstants {
 
    private xtoken:string = "";
 

    public get_cookie(){
       
        this.xtoken = (document.cookie.split(';').map(c=>c.trim()).filter(c=>c.startsWith('csrftoken'+'=')))[0].split('=')[1]
        return this.xtoken;
    }
 


}

export default new CookieConstants() ....


import Variables from '../Global.ts';

  let response = await fetch(Variables.get_Base_Url()+'/api/hospital-app/ask_corner/admin/logout/', {
          method: 'GET',
          headers: {
            Accept: 'application/json',
            'Content-Type': 'application/json',
           withCredentials: true,
            'X-CSRFToken' :  CookieConstants.get_cookie()
          },

        }); 

Comments

Popular posts from this blog

interview questions js[ Anurag Singh ProCodrr]

reactnative_creation