Angular 2 XMLHttpRequest can not load

1

I'm trying to do a POST request to an API and am getting this error:

  

XMLHttpRequest can not load http: // *. Response for preflight has invalid HTTP status code 400

However, when I make a GET request it works.

My get method:

getPerfis() {
    return this.http.get<PerfilModel[]>(globals.BASE_URL + 'perfis');
}

My post method:

updateFirstAccess(alterarSenha: AlterarSenhaModel) {
    let h = new Headers();
    h.append('Content-Type', 'application/json');

    return this.http2.post(globals.BASE_URL + 'usuarios/senhas/redefinicoes/' + 
      alterarSenha.chave, JSON.stringify(alterarSenha), { headers: h }
    ).map(res => res.json);
}

ps: the toggle cors plugin is enabled.

    
asked by anonymous 28.08.2017 / 19:24

0 answers