I need to make an HTTP POST request with x-www-form-urelcoded in angle 6.
I tried something like:
pesquisaEmail(email): Observable<any>{
let headers = new HttpHeaders();
headers.append('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
headers.append('Content-Type', 'application/x-www-form-urlencoded');
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}))
)}
}
@Edit I've also tried:
pesquisaEmail(email): Observable<any>{
let headers = new HttpHeaders();
headers.append('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
headers.append('Content-Type', 'application/x-www-form-urlencoded');
this.token = localStorage.getItem('currentUser');
let body = new URLSearchParams();
body.set('email', this.token);
body.set('token_jc', email);
return this._http.post<any>(AppSettings.API_ENDPOINT_EMAIL,
body,
{ headers: headers, observe: 'response' })
.pipe(
map((response) => ({data: response.body, status: response.status}))
)}
}
but unsuccessful
I get a bad request error. Does anyone know how I can make this type of request?