Comparing version 5.3.7 to 5.3.8
@@ -96,3 +96,3 @@ 'use strict'; | ||
var list = resource.split('.'); | ||
var method = list.shift(); | ||
var method = list.shift().toUpperCase(); | ||
var path = list.reduce(toPath.bind(null, params), ''); | ||
@@ -109,8 +109,13 @@ | ||
return fetch('' + url + path + getQueryString(query), { | ||
method: method.toUpperCase(), | ||
headers: headers, | ||
body: method === 'get' || method === 'head' ? null : JSON.stringify(body) | ||
}); | ||
var requestOptions = { | ||
method: method, | ||
headers: headers | ||
}; | ||
if (method !== 'GET' && method !== 'HEAD') { | ||
requestOptions.body = JSON.stringify(body); | ||
} | ||
return fetch('' + url + path + getQueryString(query), requestOptions); | ||
function toPath(params, path, res) { | ||
@@ -117,0 +122,0 @@ if (params[res] === undefined || params[res] === null) { |
@@ -285,3 +285,3 @@ 'use strict'; | ||
expect(requestOptions.method).toBe('GET'); | ||
expect(requestOptions.body).toBe(null); | ||
expect(requestOptions.body).toBe(undefined); | ||
@@ -288,0 +288,0 @@ run(); |
{ | ||
"name": "rxws", | ||
"version": "5.3.7", | ||
"version": "5.3.8", | ||
"description": "A RESTful reactive JavaScript implmentation on top of web sockets", | ||
@@ -5,0 +5,0 @@ "main": "lib/rxws.js", |
@@ -81,3 +81,3 @@ import { Observable } from 'rx'; | ||
let list = resource.split('.'); | ||
const method = list.shift(); | ||
const method = list.shift().toUpperCase(); | ||
const path = list.reduce(toPath.bind(null, params), ''); | ||
@@ -95,8 +95,13 @@ | ||
return fetch(`${url}${path}${getQueryString(query)}`, { | ||
method: method.toUpperCase(), | ||
let requestOptions = { | ||
method, | ||
headers, | ||
body: (method === 'get' || method === 'head') ? null : JSON.stringify(body) | ||
}) | ||
}; | ||
if (method !== 'GET' && method !== 'HEAD') { | ||
requestOptions.body = JSON.stringify(body); | ||
} | ||
return fetch(`${url}${path}${getQueryString(query)}`, requestOptions) | ||
function toPath(params, path, res) { | ||
@@ -103,0 +108,0 @@ if (params[res] === undefined || params[res] === null) { |
@@ -294,3 +294,3 @@ import backend from './HTTPBackend'; | ||
expect(requestOptions.method).toBe('GET'); | ||
expect(requestOptions.body).toBe(null); | ||
expect(requestOptions.body).toBe(undefined); | ||
@@ -297,0 +297,0 @@ run(); |
603051
15796