Skip to content

Commit

Permalink
add more request options and fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
ThobyV committed Sep 16, 2020
1 parent 9858c7e commit b1fe596
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Method alias
// cancelRequest
// config
// responstype
// validateStatus
// default
// req/res interceptors
// final state of every request is always defaulted by null,something or overwritten

(function create(options) {
function deepMerge(base, config) {
const newObj = Object.assign({}, base, config);
Expand Down Expand Up @@ -59,9 +50,11 @@
return request(config);
}

function m(method) {
const s = 'set';

function m(method, type) {
return function (url, data, config) {
if (!config) {
if (!config && type !== s) {
config = data;
data = null;
}
Expand Down Expand Up @@ -136,9 +129,11 @@
lit.defaults = defaults;
lit.get = m('GET');
lit.delete = m('DELETE');
lit.post = m('POST');
lit.put = m('PUT');
lit.patch = m('PATCH');
lit.head = m('HEAD');
lit.options = m('OPTIONS');
lit.post = m('POST', s);
lit.put = m('PUT', s);
lit.patch = m('PATCH', s);

return lit;
})();

0 comments on commit b1fe596

Please sign in to comment.