mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
docs(defaults/index)
This commit is contained in:
@@ -13,12 +13,28 @@ var DEFAULT_CONTENT_TYPE = {
|
|||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the headers object is not undefined and the Content-Type property of the headers object
|
||||||
|
* is undefined, then set the Content-Type property of the headers object to the value passed
|
||||||
|
* in
|
||||||
|
*
|
||||||
|
* @param {Object<string, string>} headers - The headers object that will be sent to the server.
|
||||||
|
* @param {any} value - The value of the Content-Type header.
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
function setContentTypeIfUnset(headers, value) {
|
function setContentTypeIfUnset(headers, value) {
|
||||||
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
||||||
headers['Content-Type'] = value;
|
headers['Content-Type'] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
||||||
|
* adapter
|
||||||
|
*
|
||||||
|
* @returns {Function}
|
||||||
|
*/
|
||||||
function getDefaultAdapter() {
|
function getDefaultAdapter() {
|
||||||
var adapter;
|
var adapter;
|
||||||
if (typeof XMLHttpRequest !== 'undefined') {
|
if (typeof XMLHttpRequest !== 'undefined') {
|
||||||
@@ -31,6 +47,16 @@ function getDefaultAdapter() {
|
|||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
||||||
|
* of the input
|
||||||
|
*
|
||||||
|
* @param {any} rawValue - The value to be stringified.
|
||||||
|
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
||||||
|
* @param {Function} encoder - A function that takes a value and returns a string.
|
||||||
|
*
|
||||||
|
* @returns {string} A stringified version of the rawValue.
|
||||||
|
*/
|
||||||
function stringifySafely(rawValue, parser, encoder) {
|
function stringifySafely(rawValue, parser, encoder) {
|
||||||
if (utils.isString(rawValue)) {
|
if (utils.isString(rawValue)) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user