Ionic 3 how to use withCredentials to save cookies after request

Viewed 799

I have to save cookies after the API response in my Ionic 3 application and I can not do this, I need your help.

I create an interceptor before the request and setup on all results "withCredentials = true" but this does not work, do you have other resources to do this? Follow my code below

private getRequestOptionArgs(options?: RequestOptionsArgs) : RequestOptionsArgs {

    if (options == null) {
        options = new RequestOptions({ withCredentials: true });
    }
    if (options.headers == null) {
        options.headers = new Headers();
    }

    options.headers.append('Content-Type', 'application/json');
    options.headers.append('Access-Control-Allow-Credentials', 'true');
    options.headers.append('Access-Control-Allow-Origin', '*');

    options.withCredentials = true

    return options;
}
0 Answers
Related