import fetch from 'isomorphic-fetch';
import Q from 'q';

var credentials = 'include';
export function get(url){
	return Q(fetch(url, {credentials})).then(handle);
}

export function put(url, body){
	const method = 'put';
	return Q(fetch(url, {method, body, credentials})).then(handle);
}

export function post(url, body){
	console.log('post', url, body);
	const method = 'post';
	return Q(fetch(url, {
		method
		, headers: {
			'Accept': 'application/json',
			'Content-Type': 'application/json'
		}
		, body: JSON.stringify(body)
		, credentials
	})).then(handle);
}

function handle(response){
	return response.json()
	.then(obj=>{
		if(response.status>=400){
			throw obj;
			return obj;
		}

		return obj;
	})
}
@@ -103,18 +103,174 @@
  get(url
-)%7B
+, body)%7B%0A%09if(body)%7B%0A%09%09var querystring = _.map(body, (v,k)=%3E%60$%7BencodeURIComponent(k)%7D=$%7BencodeURIComponent(v)%7D%60).join('&');%0A%09%09url = url + '?' + querystring;%0A%09%7D
 %0A%09return
@@ -397,20 +397,141 @@
 l, %7B
+%0A%09%09
 method
-, body
+%0A%09%09, headers: %7B%0A%09%09%09'Accept': 'application/json',%0A%09%09%09'Content-Type': 'application/json'%0A%09%09%7D%0A%09%09, body: JSON.stringify(body)%0A%09%09
 , cr
@@ -531,32 +531,34 @@
 %0A%09%09, credentials
+%0A%09
 %7D)).then(handle)
@@ -843,16 +843,149 @@
 le);%0A%7D%0A%0A
+export function __delete(url, body)%7B%0A%09const method = 'delete';%0A%09return Q(fetch(url, %7B%0A%09%09method%0A%09%09, credentials%0A%09%7D)).then(handle);%0A%7D%0A%0A
 function

Fix request boilerplate