wonderful-fetch
Advanced tools
Comparing version 1.1.8 to 1.1.9
@@ -25,3 +25,3 @@ (function (root, factory) { | ||
var SOURCE = 'library'; | ||
var VERSION = '1.1.8'; | ||
var VERSION = '1.1.9'; | ||
@@ -60,2 +60,3 @@ function WonderfulFetch(url, options) { | ||
// Check if URL is provided | ||
if (!url) { | ||
@@ -65,7 +66,10 @@ return reject(new Error('No URL provided.')) | ||
// Build configuration | ||
var config = { | ||
method: (options.method || 'get').toLowerCase(), | ||
headers: options.headers || {}, | ||
body: null, | ||
} | ||
// Format body | ||
if (options.body) { | ||
@@ -81,5 +85,3 @@ if (bodyIsFormData) { | ||
// if (options.json && options.body && config.method === 'post') { | ||
// config.headers['Content-Type'] = 'application/json'; | ||
// } | ||
// Set content type | ||
if ( | ||
@@ -92,6 +94,9 @@ (bodyIsObject && !bodyIsFormData) | ||
// GET requests should not have a body or content type | ||
if (config.method === 'get') { | ||
delete config.body; | ||
delete config.headers['Content-Type']; | ||
} | ||
// Log | ||
if (options.log) { | ||
@@ -101,4 +106,6 @@ console.log('Fetch configuration:', 'bodyIsFormData=' + bodyIsFormData, 'bodyIsObject=' + bodyIsObject, options, config); | ||
// Set timeout | ||
var timeoutHolder; | ||
// Fetch | ||
function _fetch() { | ||
@@ -293,3 +300,2 @@ var ms = Math.min((3000 * (tries - 1)), 60000); | ||
// Reference | ||
@@ -296,0 +302,0 @@ if (environment === 'browser') { |
{ | ||
"name": "wonderful-fetch", | ||
"version": "1.1.8", | ||
"version": "1.1.9", | ||
"description": "A wrapper around fetch.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
19508
261