From 6d0eb93a8d4eb25a991e19822b4dee78cd8aef76 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Tue, 28 Jan 2020 18:10:29 +0100 Subject: [PATCH] refactor(http-client): set xsrf token on post requests --- frontend/src/services/http-client/http-client.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/services/http-client/http-client.js b/frontend/src/services/http-client/http-client.js index 6ba2341f0..4ea725d2f 100644 --- a/frontend/src/services/http-client/http-client.js +++ b/frontend/src/services/http-client/http-client.js @@ -1,3 +1,5 @@ +import Cookies from 'js-cookie'; + export class HttpClient { static ACCEPT = { @@ -20,6 +22,8 @@ export class HttpClient { post(args) { args.method = 'POST'; + args.headers = args.headers || {}; + args.headers['X-XSRF-TOKEN'] = Cookies.get('XSRF-TOKEN'); return this._fetch(args); }