R
R
Roman Rakzin2020-04-11 16:15:55
Angular
Roman Rakzin, 2020-04-11 16:15:55

How to get a cookie in Angular and save it?

I'm trying to fetch the cookie, because using the standard Angular httpClient, cookies are not saved and I can't get them.
I write like this

public urlapi = 'https://server.com/api';
  private httpOptions = {
    headers: new HttpHeaders({
      'Content-Type':  'application/json',
      'X-SourceId': '11111111111'
    })
  };  //если я добавлю withCredentials: boolean, то сервер не отдаёт данные


this.http
      .post(this.urlapi, postBody, this.httpOptions)
      .pipe(map(data => { ........... }

I get the data, but I can’t get the headers, and the cookies themselves are not overwritten. What can be done? Thanks

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question