Comparing version 1.1.0 to 1.2.0
@@ -42,3 +42,4 @@ 'use strict'; | ||
data = args[1], | ||
callback = args[2]; | ||
headers = args[2], | ||
callback = args[3]; | ||
@@ -50,2 +51,3 @@ | ||
data = null; | ||
headers = {}; | ||
} | ||
@@ -56,4 +58,14 @@ | ||
data = null; | ||
headers = {}; | ||
} | ||
if (typeof headers === 'function') { | ||
callback = headers; | ||
headers = {}; | ||
} | ||
if (headers === null) { | ||
headers = {}; | ||
} | ||
var useMethod = method.toUpperCase(); | ||
@@ -87,2 +99,6 @@ var validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS']; | ||
Object.keys(headers).forEach(function (header) { | ||
xhr.setRequestHeader(header, headers[header]); | ||
}); | ||
if (data !== null) { | ||
@@ -89,0 +105,0 @@ xhr.setRequestHeader('Content-Type', 'application/json'); |
@@ -19,3 +19,3 @@ /* eslint-env browser */ | ||
static request(url, ...args) { | ||
let [method, data, callback] = args; | ||
let [method, data, headers, callback] = args; | ||
@@ -26,2 +26,3 @@ if (typeof method === 'function') { | ||
data = null; | ||
headers = {}; | ||
} | ||
@@ -32,4 +33,14 @@ | ||
data = null; | ||
headers = {}; | ||
} | ||
if (typeof headers === 'function') { | ||
callback = headers; | ||
headers = {}; | ||
} | ||
if (headers === null) { | ||
headers = {}; | ||
} | ||
const useMethod = method.toUpperCase(); | ||
@@ -63,2 +74,6 @@ const validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS']; | ||
Object.keys(headers).forEach(header => { | ||
xhr.setRequestHeader(header, headers[header]); | ||
}); | ||
if (data !== null) { | ||
@@ -65,0 +80,0 @@ xhr.setRequestHeader('Content-Type', 'application/json'); |
{ | ||
"name": "bequest", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "An ajax class", | ||
@@ -13,3 +13,6 @@ "main": "dist/ajax.js", | ||
"watch": { | ||
"lib/ajax.js": ["lint", "build"] | ||
"lib/ajax.js": [ | ||
"lint", | ||
"build" | ||
] | ||
}, | ||
@@ -33,5 +36,5 @@ "keywords": [ | ||
"concurrently": "^2.2.0", | ||
"eslint": "^3.5.0", | ||
"eslint-config-firstandthird": "^3.0.2", | ||
"eslint-plugin-import": "^1.15.0", | ||
"eslint": "^3.9.1", | ||
"eslint-config-firstandthird": "^3.1.0", | ||
"eslint-plugin-import": "^2.1.0", | ||
"nswatch": "^0.2.0", | ||
@@ -38,0 +41,0 @@ "static-server": "^2.0.3" |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12547
7
159
0