How to work with django csrftoken in angular2?

Good day,

How to work with django csrftoken in angular2?
Yet that did not prevent the development, wrote kostalek
document.cookie.replace(/(?:(?:^|.*;\s*)csrftoken\s*\=\s*([^;]*).*$)|^.*$/, "$1");

But after adding dependency angular2-cookie even this method became unavailable
July 2nd 19 at 14:24
1 answer
July 2nd 19 at 14:26
Solution
Solved the problem in General terms. Though not without a little crutch, but it seems different not yet.
Then either use for authentication page which will be generated on the django app, or when you submit the form with the application for angular2 privately to generate the same django form for the correct token.
Well, due to the package angular2-cookie appeal to the token is replaced with this:
document.cookie.replace(/(?:(?:^|.*;\s*)csrftoken\s*\=\s*([^;]*).*$)|^.*$/, "$1");

on here is:
this.cookie.get('csrftoken');

If someone has a better solution, I will be glad to know him

Find more questions by tags Angular