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

152
Views
Angular http post request fails, but axios one works

I'm doing a POST request with Angular 9 HttpClient but it fails with 'Provisional headers are shown'

My code is like:

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()
);

The same call works with 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);
  });

It is definitely some Angular config, I try a bunch but nothing works. Can someone advise about possible issues and how to configure Angular http to act like axios?

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

0

Since a lot of headaches, I figure it out. The issue was related with CORS, it was failing, because Angular HTTP has sent OPTIONS to the server. I just make a request without any headers and without reportProgress: true,

just like that

const req = new HttpRequest(method, url, bytes);

return this.http.request(req).pipe(
  map((event) => {
    if (multyStepsUpload) {
      return;
    }
    return this.reportUploadEvent(event, file);
  }),
  last()
);

And start working

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!