I use the standard way of using X-CSRF-TOKEN in Angular 2 like this in my app.module:
provide: XSRFStrategy, useValue: new CookieXSRFStrategy('CSRF-TOKEN', 'X-CSRF-TOKEN')
I am using "primeng" for file-upload. I need to set up the token by my self like this:
private onBeforeSend(event) {
event.xhr.setRequestHeader("X-CSRF-TOKEN", tokenThatINeed);
}
I need that token that Angular2 has generated for me. I don't know how to access the token.
you can get your token with the following code
document.cookie