0

I am trying to use HTTPClient to upload a form to my backend server (Java/Springboot). When I try to add the authorization header, the network debug does not show the header added in my post request for upload.

Here is the code that I am using

import { HttpClient, HttpHeaders } from '@angular/common/http';

.....
....


let httpHeaders = new HttpHeaders();
httpHeaders = httpHeaders.set('Authorization', 'Bearer ' + AuthService.getToken());

this.http.post(serverURL, formData, {headers : httpHeaders}).subscribe(
  (res) => console.log('server response =' + JSON.stringify(res)),
  (err) => console.log('server err =' + JSON.stringify(err))
);

Here are the screenshots from the network debug

enter image description here

enter image description here

enter image description here

Can some one please suggest what could have caused this?

1

1 Answer 1

0
let httpHeaders = new HttpHeaders()
.set('Authorization', 'Bearer ' + AuthService.getToken());

You can use like this

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.