From 82f8ed3b4af267d10a07780643ec8ffc29bfcf44 Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 15:39:44 -0500 Subject: [PATCH] Adding headers to post function. --- client/coral-framework/store/actions/items.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index 8aea884ad..2caf96ce2 100644 --- a/client/coral-framework/store/actions/items.js +++ b/client/coral-framework/store/actions/items.js @@ -178,19 +178,22 @@ export function postItem (item, type, id) { } let options = { method: 'POST', - body: JSON.stringify(item) + body: JSON.stringify(item), + headers: { + 'Content-Type':'application/json' + } } console.log('postItem', options); return fetch('/api/v1/' + type, options) .then( response => { - return response.ok ? response.json() + return response.ok ? response.text() : Promise.reject(response.status + ' ' + response.statusText) } ) - .then((json) => { - dispatch(addItem(json)) - return json.id + .then((id) => { + dispatch(addItem({...item, id})) + return id }) } }