Angular 2 Xmlhttprequest cannot load

Asked

Viewed 70 times

1

I am trying to make a POST request for an API and am getting this error:

Xmlhttprequest cannot 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.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.