Http Post Header

its me… I dont find any solution for my Problem. I dont get my Bearer Token in variable.

here is my header and my script ![




Can anyone help me pls. :slight_smile: How can i get this Bearer Token and can save it in Localstorage. Any solutions?

You can try 2 methods.

  1. When creating the headers, create it with all the necessary items:
  let headers: HttpHeaders = new HttpHeaders({
    "Content-Type": "application/json",
    "Content-Type": "application/x-ww-form-urlencoded",
    "Access-Control-Allow_Origin": "*",
    "Access-Control-Allow_Origin": "POST, GET, OPTIONS",
  1. When appending a new header, or doing any kind of edit, you have to assign it to ‘xxx’ (e.g. itself).
  let headers: HttpHeaders = new HttpHeaders({ "Content-Type": "application/json" });
  headers = headers.append("Content-Type": "application/x-ww-form-urlencoded");
  headers = headers.append("Access-Control-Allow_Origin": "*");
  headers = headers.append("Access-Control-Allow_Methods": "POST, GET, OPTIONS");

But i do this in my code to with headers.append??

No you do:
headers.append(“Content-Type”: “application/x-ww-form-urlencoded”);

you have to do:
headers = headers.append(“Content-Type”: “application/x-ww-form-urlencoded”);

Okay i add this to my code. But how can i store my Bearer Token :confused: I really dont know…

What do you mean with ‘store Bearer token’?

I mean this. after the Word: Bearer

I want to store this token in LocalStorage. (eyJ0eXAi…)

First of all: Read the docs:
Watch some videos:

You’ll have to understand what you’re working with first. Then you can go on with trying to understand and learn the ‘thing’ you are working with.

After understanding what you’re doing, go read more in depth for more information about for example the (Angular) HttpHeaders: (You answer is in here… : ))

Good luck!

code in your server

header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");