Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
La solicitud de publicación http angular falla, pero axios one funciona

Estoy haciendo una solicitud POST con Angular 9 HttpClient pero falla con 'Se muestran encabezados provisionales'

Mi código es como:

 const header = { headers: new HttpHeaders({ 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/x-www-form-urlencoded', }) }; const req = new HttpRequest('POST', url, bytes, { headers: header.headers, reportProgress: true, }); return this.http.request(req).pipe( map((event) => { if (multyStepsUpload) { return; } return this.reportUploadEvent(event, file); }), last() );

La misma llamada funciona con AXIOS

 return new Observable<any>((obs) => { axios.post( `${url}`, bytes, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, } ).then((res) =>{ console.log(res) ; obs.next(res); }).catch((err) => { console.log(err) ; obs.next(err); });

Definitivamente es una configuración angular, intento un montón pero nada funciona. ¿Alguien puede aconsejarme sobre posibles problemas y cómo configurar Angular http para que actúe como axios?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Como muchos dolores de cabeza, lo descubro. El problema estaba relacionado con CORS, estaba fallando porque Angular HTTP envió OPCIONES al servidor. Acabo de hacer una solicitud sin encabezados y sin reportProgress: true,

así

 const req = new HttpRequest(method, url, bytes); return this.http.request(req).pipe( map((event) => { if (multyStepsUpload) { return; } return this.reportUploadEvent(event, file); }), last() );

y empezar a trabajar

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!