Bad request requsition http post angular

Asked

Viewed 672 times

0

When performing an http post request, I am receiving:

Object { headers: {...}, status: 400, statusText: "Bad Request", url: "https://hidden address", ok: false, name: "Httperrorresponse", message: "Http Failure Response is https://hidden address 400 Bad Request", error: {...} }

My service that sends the post:

  pesquisaEmail(email): Observable<any>{
    let headers = new HttpHeaders();
    headers = headers.set('Content-Type', 'application/json; charset=utf-8');
    headers.append('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
    this.token = localStorage.getItem('currentUser');

    return this._http.post<any>(AppSettings.API_ENDPOINT_EMAIL,
      {email: email,
      token_jc: this.token },
      { headers: headers, observe: 'response' })
        .pipe(
          map((response) => ({data: response.body, status: response.status}))
        )}

my backend api expects an email key with email and another token key with token value that is stored in localstorage. 'Cause I get a bad request?

  • And the hidden error? error: {…}

  • error: {...} contaMP1: null contaMP2: null contaMP3: null accounts: Array [] modules: Array [] flat: "Trial" Whatsapp: null flat;proto: {…}

  • are the fields and values that the api should return me filled

No answers

Browser other questions tagged

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