Skip to content

Commit

Permalink
Merge pull request #6 from mdkn/add-Content-type-application/x-www-fo…
Browse files Browse the repository at this point in the history
…rm-urlencoded

add Content-type: application/x-www-form-urlencoded
  • Loading branch information
vvatanabe authored Sep 9, 2019
2 parents 8b45a9a + b1c8f5e commit 8b19572
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 86 deletions.
27 changes: 9 additions & 18 deletions dist/backlog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Backlog = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Backlog = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
Expand Down Expand Up @@ -653,7 +653,13 @@ var Request = (function () {
init.mode = 'cors';
}
if (method !== 'GET') {
init.body = params instanceof FormData ? params : this.toFormData(params);
if (params instanceof FormData) {
init.body = params;
}
else {
init.headers['Content-type'] = 'application/x-www-form-urlencoded';
init.body = this.toQueryString(params);
}
}
else {
Object.keys(params).forEach(function (key) { return query[key] = params[key]; });
Expand Down Expand Up @@ -682,21 +688,6 @@ var Request = (function () {
Request.prototype.parseJSON = function (response) {
return response.json();
};
Request.prototype.toFormData = function (params) {
return Object.keys(params).reduce(function (result, key) {
var value = params[key];
if (!value) {
return result;
}
if (Array.isArray(value)) {
value.forEach(function (v) { return result.append(key + "[]", v); });
}
else {
result.append(key, value);
}
return result;
}, new FormData());
};
Request.prototype.toQueryString = function (params) {
return Object.keys(params).reduce(function (result, key) {
var value = params[key];
Expand Down Expand Up @@ -732,4 +723,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Request;

},{"./error":3}]},{},[4])(4)
});
});
Loading

0 comments on commit 8b19572

Please sign in to comment.