Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Tela de login não funciona no instalura

Estou tentando autenticar pelo endereço https://instalura-api.herokuapp.com/api/public/login e estou recebendo o erro 405, com a seguinte mensagem: "{"timestamp":1549045493225,"status":405,"error":"Method Not Allowed","exception":"org.springframework.web.HttpRequestMethodNotSupportedException","message":"Request method 'GET' not supported","path":"/api/public/login"}";

Estou fazendo uma requisição POST, conforme código abaixo:

< envia(event){ event.preventDefault();

    const requestInfo = {
        method:'POST',
        body:JSON.stringify({login:this.login.value,senha:this.senha.value}),
        headers:new Headers({
            'Content-type' : 'application/json' 
        })
    };

    fetch('https://instalura-api.herokuapp.com/api/public/login')
        .then(response => {
            if (response.ok)
            {
                return response.text();
            }
            else
            {
                console.log(response.text());

                throw new Error('não foi possível logar.');
            }
        })
        .then(token =>{
            localStorage.setItem('auth-token', token);
            browserHistory.push('/timeline');
        })
        .catch(error =>{
            this.setState({msg:error.message});
        });
}
1 resposta
solução!

Não estava funcionando pois não tinha colocado a constante requestInfo dentro do fetch