Невозможно получить идентификатор сессии при вызове API с помощью React

export default function Index(){
    // const [auth, setAuth] = useState();
    const authenticateSpotify = ()=>{
        fetch('http://localhost:8000/spotify/is-authenticated')
        .then((response) => response.json())
        .then((data) => {   
            // setAuth(data.status);
            console.log(Cookies.get('sessionid'));
            console.log(data);
            if(!(data.status)){
                fetch('http://localhost:8000/spotify/auth')
                .then((response) => response.json())
                .then((data) => {
                    window.location.replace(data.url);
                })
                // console.log('Hii');
            }
        })
    }
    return(
        <div>
            <h1>Hello</h1>
            <Button variant="contained" onClick={(e)=>{
                e.preventDefault(); 
                authenticateSpotify();
            }}>Hello World</Button>
          
        </div>
    );    
}

Когда я нажимаю на кнопку, я получаю Введите описание изображения здесь

В другом случае, когда я открываю http://localhost:8000/spotify/is-authenticated. он показывает мне статус true и возвращает id сессии. Запутался, пожалуйста, помогите Github repo для полного кода: https://github.com/pradhyumanarora/test

Вернуться на верх