2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

docs(defaults/index)

This commit is contained in:
Jay
2022-06-02 20:52:04 +02:00
parent e8dd5cb1ed
commit 0148e4563d
+26
View File
@@ -13,12 +13,28 @@ var DEFAULT_CONTENT_TYPE = {
'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) {
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
headers['Content-Type'] = value;
}
}
/**
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
* adapter
*
* @returns {Function}
*/
function getDefaultAdapter() {
var adapter;
if (typeof XMLHttpRequest !== 'undefined') {
@@ -31,6 +47,16 @@ function getDefaultAdapter() {
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) {
if (utils.isString(rawValue)) {
try {