From 6a41ea91714711f2edc07af0329621de3191aa22 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 17 Jun 2016 21:05:30 -0700 Subject: add fetchApi.put shortcut --- web/src/js/utils.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'web/src/js/utils.js') diff --git a/web/src/js/utils.js b/web/src/js/utils.js index 2e5c3005..2e25016e 100644 --- a/web/src/js/utils.js +++ b/web/src/js/utils.js @@ -109,7 +109,19 @@ export function fetchApi(url, options) { url += "&" + xsrf; } return fetch(url, { - ...options, - credentials: 'same-origin' + credentials: 'same-origin', + ...options }); -} \ No newline at end of file +} + +fetchApi.put = (url, json, options) => fetchApi( + url, + { + method: "PUT", + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(json), + ...options + } +) -- cgit v1.2.3