From c8bc9e00b82d73260417dde0e0be57faa045da75 Mon Sep 17 00:00:00 2001 From: Arun Kaushik <46048646+incrediblenura@users.noreply.github.com> Date: Sun, 9 Nov 2025 21:49:07 +0530 Subject: [PATCH 1/9] Added hindi translation for axios docs Hindi Language Docs Translation Support Added --- hi.lang.js | 158 ++++++++++++++++++++++++++++++++++++++++++++++++ inert.config.js | 7 +++ 2 files changed, 165 insertions(+) create mode 100644 hi.lang.js diff --git a/hi.lang.js b/hi.lang.js new file mode 100644 index 00000000..5460a041 --- /dev/null +++ b/hi.lang.js @@ -0,0 +1,158 @@ +/** + * Configuration for the english (original) translation + */ + +module.exports = { + // Language display name. MUST BE THE SAME AS IN [inert.config.js].custom.langs + display: "हिंदी", + prefix: "/hi/", + dir: "ltr", + lang: "hi", + // `p` stands for `paragraph`. This will contain translations of full text blocks + // + p: { + headline: "ब्राउज़र और node.js के लिए Promise आधारित HTTP क्लाइंट", + subhead: `Axios ब्राउज़र और node.js के लिए एक सरल प्रॉमिस-आधारित HTTP क्लाइंट है। Axios एक छोटे पैकेज में एक बहुत ही एक्सटेंसिबल इंटरफ़ेस के साथ उपयोग में आसान लाइब्रेरी प्रदान करता है।`, + sponsors: `

हमारे प्रोजेक्ट का समर्थन करने के लिए धन्यवाद।

+

अगर आपके द्वारा चुना गया स्तर यह लाभ प्रदान करता है, तो आपको 24 घंटों के भीतर स्वचालित रूप से इस सूची में जोड़ दिया जाएगा।

+
और पढ़ें...
+ `, + }, + // `t` stands fot `translation`. This will contain translations of single words or phrases + t: { + "Get Started": 'शुरु करें', + "View on GitHub": 'GitHub पर देखें', + "Languages": 'भाषाऐं', + "Open Source": 'Open Source', + "Contribute": 'योगदान करें', + "Source on GitHub": 'GitHub पर स्रोत', + "Issues": 'समस्याऐं', + "Pull Requests": 'undefined', + "Code of Conduct": 'Code of Conduct', + "Fork on GitHub": "GitHub में फोर्क करें", + "Fork the Website": "Website फोर्क करें", + "Create an Issue": "समस्या बनाऐं", + "Next": 'अगला', + "Previous": "पिछला", + "Website Copy Right Footer": 'Website कॉपीराईट फुटर', + "View On Github": 'GitHub पर देखें', + "Axios Project Copy Right Footer": 'Axios प्रोजेक्ट कॉपीराईट फुटर', + "License Label Footer": 'लाईसेंस लेबल फुटर', + "Sponsors": 'प्रायोजक', + "Become a sponsor": 'प्रायोजक', + "Gold Sponsors": 'गॊल्ड प्रायोजक', + }, + sidebar: [ + { + type: "heading", + text: "शुरु करें", + }, + { + type: "link", + href: "/docs/intro", + text: "भूमिका", + }, + { + type: "link", + href: "/docs/example", + text: "उदाहरण", + }, + { + type: "link", + href: "/docs/post_example", + text: "POST Requests", + }, + { + type: "heading", + text: "Axios API", + }, + { + type: "link", + href: "/docs/api_intro", + text: "Axios API भूमिका", + }, + { + type: "link", + href: "/docs/instance", + text: "The Axios Instance", + }, + { + type: "link", + href: "/docs/req_config", + text: "Request Config", + }, + { + type: "link", + href: "/docs/res_schema", + text: "Response Schema", + }, + { + type: "link", + href: "/docs/config_defaults", + text: "Config Defaults", + }, + { + type: "link", + href: "/docs/interceptors", + text: "Interceptors", + }, + { + type: "link", + href: "/docs/handling_errors", + text: "त्रुटियों से निपटना", + }, + { + type: "link", + href: "/docs/cancellation", + text: "रद्द करना", + }, + { + type: "link", + href: "/docs/urlencoded", + text: "🆕 URL-एन्कोडिंग", + }, + { + type: "link", + href: "/docs/multipart", + text: "🆕 मल्टीपार्ट बॉडीज़", + }, + { + type: "heading", + text: "अन्य", + }, + { + type: "link", + href: "/docs/notes", + text: "नोट्स", + }, + { + type: "heading", + text: "सहयोजक", + }, + { + type: "link", + href: "/docs/sponsor", + text: "Axios के प्रायोजक", + }, + { + type: "link", + href: "https://github.com/axios/axios/blob/v1.x/CODE_OF_CONDUCT.md", + text: "आचार संहिता", + }, + { + type: "link", + href: "https://github.com/axios/axios/blob/v1.x/COLLABORATOR_GUIDE.md", + text: "सहयोगी मार्गदर्शिका", + }, + { + type: "link", + href: "https://github.com/axios/axios/blob/v1.x/CONTRIBUTING.md", + text: "Axios में योगदान", + }, + { + type: "link", + href: "/docs/translating", + text: "इन दस्तावेज़ों का अनुवाद", + }, + ], +}; diff --git a/inert.config.js b/inert.config.js index 8a9dd2a8..53eb9608 100644 --- a/inert.config.js +++ b/inert.config.js @@ -16,6 +16,7 @@ const { const fs = require("fs"); +const hiConfig = require("./hi.lang.js"); const arConfig = require("./ar.lang.js"); const enConfig = require("./en.lang.js"); const deConfig = require("./de.lang.js"); @@ -88,6 +89,12 @@ const langs = [ prefix: "/fr/", config: frConfig, }, + { + dir: "ltr", + name: "हिंदी", + prefix: '/hi/', + config: hiConfig + }, { dir: "ltr", name: "Türkçe", From cbacbdac24fd780a01de1a3a5c36850d7e5b2962 Mon Sep 17 00:00:00 2001 From: Arun Kaushik <46048646+incrediblenura@users.noreply.github.com> Date: Sun, 9 Nov 2025 21:51:45 +0530 Subject: [PATCH 2/9] Create index.md --- posts/hi/index.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 posts/hi/index.md diff --git a/posts/hi/index.md b/posts/hi/index.md new file mode 100644 index 00000000..76f177f1 --- /dev/null +++ b/posts/hi/index.md @@ -0,0 +1 @@ +# Hi From 12ced47da7b9f054f8cc2923409a1cad340891d8 Mon Sep 17 00:00:00 2001 From: Arun Kaushik <46048646+incrediblenura@users.noreply.github.com> Date: Sun, 9 Nov 2025 21:53:12 +0530 Subject: [PATCH 3/9] Translation of Docs in Hindi Language Added --- posts/hi/api_intro.md | 61 +++++++++ posts/hi/cancellation.md | 144 ++++++++++++++++++++ posts/hi/config_defaults.md | 50 +++++++ posts/hi/example.md | 68 ++++++++++ posts/hi/handling_errors.md | 55 ++++++++ posts/hi/instance.md | 62 +++++++++ posts/hi/interceptors.md | 55 ++++++++ posts/hi/intro.md | 74 +++++++++++ posts/hi/multipart.md | 170 ++++++++++++++++++++++++ posts/hi/notes.md | 38 ++++++ posts/hi/post_example.md | 88 ++++++++++++ posts/hi/req_config.md | 257 ++++++++++++++++++++++++++++++++++++ posts/hi/res_schema.md | 52 ++++++++ posts/hi/sponsor.md | 90 +++++++++++++ posts/hi/translating.md | 47 +++++++ posts/hi/urlencoded.md | 119 +++++++++++++++++ 16 files changed, 1430 insertions(+) create mode 100644 posts/hi/api_intro.md create mode 100644 posts/hi/cancellation.md create mode 100644 posts/hi/config_defaults.md create mode 100644 posts/hi/example.md create mode 100644 posts/hi/handling_errors.md create mode 100644 posts/hi/instance.md create mode 100644 posts/hi/interceptors.md create mode 100644 posts/hi/intro.md create mode 100644 posts/hi/multipart.md create mode 100644 posts/hi/notes.md create mode 100644 posts/hi/post_example.md create mode 100644 posts/hi/req_config.md create mode 100644 posts/hi/res_schema.md create mode 100644 posts/hi/sponsor.md create mode 100644 posts/hi/translating.md create mode 100644 posts/hi/urlencoded.md diff --git a/posts/hi/api_intro.md b/posts/hi/api_intro.md new file mode 100644 index 00000000..e0c4e7b4 --- /dev/null +++ b/posts/hi/api_intro.md @@ -0,0 +1,61 @@ +--- +title: 'Axios API' +description: 'The Axios API Reference' +prev_title: 'POST Requests' +prev_link: '/docs/post_example' +next_title: 'The Axios Instance' +next_link: '/docs/instance' +--- + +Requests can be made by passing the relevant config to `axios`. + +##### axios(config) + +```js +// Send a POST request +axios({ + method: 'post', + url: '/user/12345', + data: { + firstName: 'Fred', + lastName: 'Flintstone' + } +}); +``` + +```js +// GET request for remote image in node.js +axios({ + method: 'get', + url: 'http://bit.ly/2mTM3nY', + responseType: 'stream' +}) + .then(function (response) { + response.data.pipe(fs.createWriteStream('ada_lovelace.jpg')) + }); +``` + +##### axios(url[, config]) + +```js +// Send a GET request (default method) +axios('/user/12345'); +``` + +### Request method aliases + +For convenience aliases have been provided for all supported request methods. + +##### axios.request(config) +##### axios.get(url[, config]) +##### axios.delete(url[, config]) +##### axios.head(url[, config]) +##### axios.options(url[, config]) +##### axios.post(url[, data[, config]]) +##### axios.put(url[, data[, config]]) +##### axios.patch(url[, data[, config]]) +##### axios.postForm(url[, data[, config]]) +##### axios.putForm(url[, data[, config]]) +##### axios.patchForm(url[, data[, config]]) + +> NOTE: When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config. diff --git a/posts/hi/cancellation.md b/posts/hi/cancellation.md new file mode 100644 index 00000000..1b0f7e1b --- /dev/null +++ b/posts/hi/cancellation.md @@ -0,0 +1,144 @@ +--- +title: 'Cancellation' +prev_title: 'Handling Errors' +prev_link: '/docs/handling_errors' +next_title: 'URL-Encoding Bodies' +next_link: '/docs/urlencoded' +--- + +## Cancelling requests + +Setting the `timeout` property in an axios call handles **response** related timeouts. + +In some cases (e.g. network connection becomes unavailable) an axios call would benefit from cancelling the **connection** early. Without cancellation, the axios call can hang until the parent code/stack times out (might be a few minutes in a server-side applications). + +To terminate an axios call you can use following methods: +- `signal` +- `cancelToken` (deprecated) + +Combining `timeout` and cancellation method (e.g. `signal`) should cover **response** related timeouts AND **connection** related timeouts. + +### `signal`: AbortController + +Starting from `v0.22.0` Axios supports [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to cancel requests in fetch API way: + +```js +const controller = new AbortController(); + +axios.get('/foo/bar', { + signal: controller.signal +}).then(function(response) { + //... +}); +// cancel the request +controller.abort() +``` + +Example with a timeout using latest [`AbortSignal.timeout()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout) API [nodejs 17.3+]: +```js +axios.get('/foo/bar', { + signal: AbortSignal.timeout(5000) //Aborts request after 5 seconds +}).then(function(response) { + //... +}); +``` + +Example with a timeout helper function: +```js +function newAbortSignal(timeoutMs) { + const abortController = new AbortController(); + setTimeout(() => abortController.abort(), timeoutMs || 0); + + return abortController.signal; +} + +axios.get('/foo/bar', { + signal: newAbortSignal(5000) //Aborts request after 5 seconds +}).then(function(response) { + //... +}); +``` + +### CancelToken `deprecated` + +You can also cancel a request using a *CancelToken*. + +> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises). + +> This API is deprecated since `v0.22.0` and shouldn't be used in new projects + +You can create a cancel token using the `CancelToken.source` factory as shown below: + +```js +const CancelToken = axios.CancelToken; +const source = CancelToken.source(); + +axios.get('/user/12345', { + cancelToken: source.token +}).catch(function (thrown) { + if (axios.isCancel(thrown)) { + console.log('Request canceled', thrown.message); + } else { + // handle error + } +}); + +axios.post('/user/12345', { + name: 'new name' +}, { + cancelToken: source.token +}) + +// cancel the request (the message parameter is optional) +source.cancel('Operation canceled by the user.'); +``` + +You can also create a cancel token by passing an executor function to the `CancelToken` constructor: + +```js +const CancelToken = axios.CancelToken; +let cancel; + +axios.get('/user/12345', { + cancelToken: new CancelToken(function executor(c) { + // An executor function receives a cancel function as a parameter + cancel = c; + }) +}); + +// cancel the request +cancel(); +``` + +> Note: you can cancel several requests with the same cancel token / signal. + +During the transition period, you can use both cancellation APIs, even for the same request: + +```js +const controller = new AbortController(); + +const CancelToken = axios.CancelToken; +const source = CancelToken.source(); + +axios.get('/user/12345', { + cancelToken: source.token, + signal: controller.signal +}).catch(function (thrown) { + if (axios.isCancel(thrown)) { + console.log('Request canceled', thrown.message); + } else { + // handle error + } +}); + +axios.post('/user/12345', { + name: 'new name' +}, { + cancelToken: source.token +}) + +// cancel the request (the message parameter is optional) +source.cancel('Operation canceled by the user.'); +// OR +controller.abort(); // the message parameter is not supported +``` diff --git a/posts/hi/config_defaults.md b/posts/hi/config_defaults.md new file mode 100644 index 00000000..fc16a5aa --- /dev/null +++ b/posts/hi/config_defaults.md @@ -0,0 +1,50 @@ +--- +title: 'Config Defaults' +prev_title: 'Response Schema' +prev_link: '/docs/res_schema' +next_title: 'Interceptors' +next_link: '/docs/interceptors' +--- + +## Config Defaults + +You can specify config defaults that will be applied to every request. + +### Global axios defaults + +```js +axios.defaults.baseURL = 'https://api.example.com'; +axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; +axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; +``` + +### Custom instance defaults + +```js +// Set config defaults when creating the instance +const instance = axios.create({ + baseURL: 'https://api.example.com' +}); + +// Alter defaults after instance has been created +instance.defaults.headers.common['Authorization'] = AUTH_TOKEN; +``` + +### Config order of precedence + +Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults/index.js](https://github.com/axios/axios/blob/v1.x/lib/defaults/index.js), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. + +```js +// Create an instance using the config defaults provided by the library +// At this point the timeout config value is `0` as is the default for the library +const instance = axios.create(); + +// Override timeout default for the library +// Now all requests using this instance will wait 2.5 seconds before timing out +instance.defaults.timeout = 2500; + +// Override timeout for this request as it's known to take a long time +instance.get('/longRequest', { + timeout: 5000 +}); +``` diff --git a/posts/hi/example.md b/posts/hi/example.md new file mode 100644 index 00000000..80019abc --- /dev/null +++ b/posts/hi/example.md @@ -0,0 +1,68 @@ +--- +title: 'Minimal Example' +description: 'A little example of using axios' +prev_title: 'Introduction' +prev_link: '/docs/intro' +next_title: 'POST Requests' +next_link: '/docs/post_example' +--- + +## note: CommonJS usage +In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach: + +```js +const axios = require('axios').default; + +// axios. will now provide autocomplete and parameter typings +``` + +# Example + +Performing a `GET` request + +```js +const axios = require('axios'); + +// Make a request for a user with a given ID +axios.get('/user?ID=12345') + .then(function (response) { + // handle success + console.log(response); + }) + .catch(function (error) { + // handle error + console.log(error); + }) + .finally(function () { + // always executed + }); + +// Optionally the request above could also be done as +axios.get('/user', { + params: { + ID: 12345 + } + }) + .then(function (response) { + console.log(response); + }) + .catch(function (error) { + console.log(error); + }) + .finally(function () { + // always executed + }); + +// Want to use async/await? Add the `async` keyword to your outer function/method. +async function getUser() { + try { + const response = await axios.get('/user?ID=12345'); + console.log(response); + } catch (error) { + console.error(error); + } +} +``` + +> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet +> Explorer and older browsers, so use with caution. \ No newline at end of file diff --git a/posts/hi/handling_errors.md b/posts/hi/handling_errors.md new file mode 100644 index 00000000..48683e5b --- /dev/null +++ b/posts/hi/handling_errors.md @@ -0,0 +1,55 @@ +--- +title: 'Handling Errors' +prev_title: 'Interceptors' +prev_link: '/docs/interceptors' +next_title: 'Cancellation' +next_link: '/docs/cancellation' +--- + +The general structure of axios errors is as follows: +- **message** - A quick summary of the error message and the status it failed with. +- **name** - This defines where the error originated from. For axios, it will always be an 'AxiosError'. +- **stack** - Provides the stack trace of the error. +- **config** - An axios config object with specific instance configurations defined by the user from when the request was made. +- **code** - Represents an axios identified error. The table below lists out specific definitions for internal axios error. +- **status** - HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings. +```js +axios.get('/user/12345') + .catch(function (error) { + if (error.response) { + // The request was made and the server responded with a status code + // that falls out of the range of 2xx + console.log(error.response.data); + console.log(error.response.status); + console.log(error.response.headers); + } else if (error.request) { + // The request was made but no response was received + // `error.request` is an instance of XMLHttpRequest in the browser and an instance of + // http.ClientRequest in node.js + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + console.log('Error', error.message); + } + console.log(error.config); + }); +``` + +Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error. + +```js +axios.get('/user/12345', { + validateStatus: function (status) { + return status < 500; // Resolve only if the status code is less than 500 + } +}) +``` + +Using `toJSON` you get an object with more information about the HTTP error. + +```js +axios.get('/user/12345') + .catch(function (error) { + console.log(error.toJSON()); + }); +``` diff --git a/posts/hi/instance.md b/posts/hi/instance.md new file mode 100644 index 00000000..bd2a757b --- /dev/null +++ b/posts/hi/instance.md @@ -0,0 +1,62 @@ +--- +title: 'The Axios Instance' +prev_title: 'Axios API' +prev_link: '/docs/api_intro' +next_title: 'Request Config' +next_link: '/docs/req_config' +--- + +### Creating an instance + +You can create a new instance of axios with a custom config. + +##### axios.create([config]) + +```js +const instance = axios.create({ + baseURL: 'https://some-domain.com/api/', + timeout: 1000, + headers: {'X-Custom-Header': 'foobar'} +}); +``` + +### Instance methods + +The available instance methods are listed below. The specified config will be merged with the instance config. + +##### axios#request(config) +##### axios#get(url[, config]) +##### axios#delete(url[, config]) +##### axios#head(url[, config]) +##### axios#options(url[, config]) +##### axios#post(url[, data[, config]]) +##### axios#put(url[, data[, config]]) +##### axios#patch(url[, data[, config]]) +##### axios#getUri([config]) + +### Calling the instance with a config object + +In addition to using convenience methods like `instance.get()` or `instance.post()`, you can also call an Axios instance directly with a config object. This is functionally equivalent to `axios(config)`, and is particularly useful when retrying a request using the original configuration. + +```js +const instance = axios.create({ baseURL: '/api' }); + +// Works just like axios(config) +instance({ + url: '/users', + method: 'get' +}); +``` + +This approach enables clean retry logic when handling authentication errors: + +```js +instance.interceptors.response.use(undefined, async (error) => { + if (error.response?.status === 401) { + await refreshToken(); + return instance(error.config); // Retry original request + } + + throw error; +}); +``` diff --git a/posts/hi/interceptors.md b/posts/hi/interceptors.md new file mode 100644 index 00000000..414790fa --- /dev/null +++ b/posts/hi/interceptors.md @@ -0,0 +1,55 @@ +--- +title: 'Interceptors' +prev_title: 'Config Defaults' +prev_link: '/docs/config_defaults' +next_title: 'Handling Errors' +next_link: '/docs/handling_errors' +--- + +You can intercept requests or responses **before** they are handled by `then` or `catch`. + +The `use` function adds a handler to the list of handlers to be run when the Promise is fulfilled or rejected. The handler is defined by the fulfilled and rejected functions. + +There is an optional `options` object that can be passed in as the third parameter. `synchronous` if the synchronous option is true. The handler is defined as asynchronous if the synchronous option is false. If the synchronous option is not provided, the handler is defined as asynchronous. `runWhen` will control when the provided interceptor will run. Provide a function that will return true or false on whether it should run, defaults to always true. + +```js +// Add a request interceptor +axios.interceptors.request.use(function (config) { + // Do something before request is sent + return config; + }, function (error) { + // Do something with request error + return Promise.reject(error); + }, + { synchronous: true, runWhen: () => /* This function returns true */} +); + +// Add a response interceptor +axios.interceptors.response.use(function onFulfilled(response) { + // Any status code that lie within the range of 2xx cause this function to trigger + // Do something with response data + return response; + }, function onRejected(error) { + // Any status codes that falls outside the range of 2xx cause this function to trigger + // Do something with response error + return Promise.reject(error); + }); +``` + +In normal circumstances the `onFulfilled` response interceptor is only called for responses in the 2xx range, and `onRejected` is called otherwise. +However, this behavior depends on [validateStatus](/docs/req_config). +For instance, if `validateStatus` is setup to always return `true`, then `onFulfilled` will be called for *all* responses. + +If you need to remove an interceptor later you can. + +```js +const myInterceptor = axios.interceptors.request.use(function () {/*...*/}); +axios.interceptors.request.eject(myInterceptor); +``` + +You can add interceptors to a custom instance of axios. + +```js +const instance = axios.create(); +instance.interceptors.request.use(function () {/*...*/}); +``` diff --git a/posts/hi/intro.md b/posts/hi/intro.md new file mode 100644 index 00000000..76b3b97f --- /dev/null +++ b/posts/hi/intro.md @@ -0,0 +1,74 @@ +--- +title: 'Getting Started' +description: 'Promise based HTTP client for the browser and node.js' +next_title: 'Minimal Example' +next_link: '/docs/example' +--- + +# What is Axios? +Axios is a *[promise-based](https://javascript.info/promise-basics)* HTTP Client for [`node.js`](https://nodejs.org) and the browser. It is *[isomorphic](https://www.lullabot.com/articles/what-is-an-isomorphic-application)* (= it can run in the browser and node.js with the same codebase). On the server-side it uses the native node.js `http` module, while on the client (browser) it uses XMLHttpRequest. + +# Features + +- Make [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser +- Make [http](http://nodejs.org/api/http.html) requests from node.js +- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API +- Intercept request and response +- Transform request and response data +- Cancel requests +- Timeouts +- Query parameters serialization with support for nested entries +- Automatic request body serialization to: + - JSON (`application/json`) + - Multipart / FormData (`multipart/form-data`) + - URL encoded form (`application/x-www-form-urlencoded`) +- Posting HTML forms as JSON +- Automatic JSON data handling in response +- Progress capturing for browsers and node.js with extra info (speed rate, remaining time) +- Setting bandwidth limits for node.js +- Compatible with spec-compliant FormData and Blob (including `node.js`) +- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) + +# Installing + +Using npm: + +```bash +$ npm install axios +``` + +Using bower: + +```bash +$ bower install axios +``` + +Using yarn: + +```bash +$ yarn add axios +``` + +Using pnpm: + +```bash +$ pnpm add axios +``` + +Using jsDelivr CDN: + +```html + +``` + +Using unpkg CDN: + +```html + +``` +Prebuilt CommonJS modules for direct importing with require (if your module bundler failed to resolve them automatically) + +```js +const axios = require('axios/dist/browser/axios.cjs'); // browser +const axios = require('axios/dist/node/axios.cjs'); // node +``` \ No newline at end of file diff --git a/posts/hi/multipart.md b/posts/hi/multipart.md new file mode 100644 index 00000000..08e3887d --- /dev/null +++ b/posts/hi/multipart.md @@ -0,0 +1,170 @@ +--- +title: 'Multipart Bodies' +prev_title: 'URL-Encoding Bodies' +prev_link: '/docs/urlencoded' +next_title: 'Notes' +next_link: '/docs/notes' +--- + +## Posting data as `multipart/form-data` + +### Using FormData API + +#### Browser + +```js +const form = new FormData(); +form.append('my_field', 'my value'); +form.append('my_buffer', new Blob([1,2,3])); +form.append('my_file', fileInput.files[0]); + +axios.post('https://example.com', form) +``` + +The same result can be achieved using the internal Axios serializer and corresponding shorthand method: + +```js +axios.postForm('https://httpbin.org/post', { + my_field: 'my value', + my_buffer: new Blob([1,2,3]), + my_file: fileInput.files // FileList will be unwrapped as separate fields +}); +``` + +HTML form can be passed directly as a request payload. + +#### Node.js + +```js +import axios from 'axios'; + +const form = new FormData(); +form.append('my_field', 'my value'); +form.append('my_buffer', new Blob(['some content'])); + +axios.post('https://example.com', form) +``` + +Since node.js does not currently support creating a `Blob` from a file, you can use a third-party package for this purpose. + +```js +import {fileFromPath} from 'formdata-node/file-from-path' + +form.append('my_field', 'my value'); +form.append('my_file', await fileFromPath('/foo/bar.jpg')); + +axios.post('https://example.com', form) +``` + +For Axios older than `v1.3.0` you must import `form-data` package. + +```js +const FormData = require('form-data'); + +const form = new FormData(); +form.append('my_field', 'my value'); +form.append('my_buffer', new Buffer(10)); +form.append('my_file', fs.createReadStream('/foo/bar.jpg')); + +axios.post('https://example.com', form) +``` + +### 🆕 Automatic serialization + +Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData +object if the request Content-Type header is set to `multipart/form-data`. + +The following request will submit the data in a FormData format (Browser & Node.js): + +```js +import axios from 'axios'; + +axios.post('https://httpbin.org/post', { + user: { + name: 'Dmitriy' + }, + file: fs.createReadStream('/foo/bar.jpg') +}, { + headers: { + 'Content-Type': 'multipart/form-data' + } +}).then(({data})=> console.log(data)); +``` + +Axios FormData serializer supports some special endings to perform the following operations: + +- `{}` - serialize the value with JSON.stringify +- `[]` - unwrap the array-like object as separate fields with the same key + +> NOTE: +> unwrap/expand operation will be used by default on arrays and FileList objects + +FormData serializer supports additional options via `config.formSerializer: object` property to handle rare cases: + +- `visitor: Function` - user-defined visitor function that will be called recursively to serialize the data object +to a `FormData` object by following custom rules. + +- `dots: boolean = false` - use dot notation instead of brackets to serialize arrays and objects; + +- `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key. +The back-end body-parser could potentially use this meta-information to automatically parse the value as JSON. + +- `indexes: null|false|true = false` - controls how indexes will be added to unwrapped keys of `flat` array-like objects + + - `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`) + - `false`(default) - add empty brackets (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`) + - `true` - add brackets with indexes (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`) + +Let's say we have an object like this one: + +```js +const obj = { + x: 1, + arr: [1, 2, 3], + arr2: [1, [2], 3], + users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], + 'obj2{}': [{x:1}] +}; +``` + +The following steps will be executed by the Axios serializer internally: + +```js +const formData= new FormData(); +formData.append('x', '1'); +formData.append('arr[]', '1'); +formData.append('arr[]', '2'); +formData.append('arr[]', '3'); +formData.append('arr2[0]', '1'); +formData.append('arr2[1][0]', '2'); +formData.append('arr2[2]', '3'); +formData.append('users[0][name]', 'Peter'); +formData.append('users[0][surname]', 'Griffin'); +formData.append('users[1][name]', 'Thomas'); +formData.append('users[1][surname]', 'Anderson'); +formData.append('obj2{}', '[{"x":1}]'); +``` + +```js +import axios from 'axios'; + +axios.post('https://httpbin.org/post', { + 'myObj{}': {x: 1, s: "foo"}, + 'files[]': document.querySelector('#fileInput').files +}, { + headers: { + 'Content-Type': 'multipart/form-data' + } +}).then(({data})=> console.log(data)); +``` + +Axios supports the following shortcut methods: `postForm`, `putForm`, `patchForm` +which are just the corresponding http methods with the content-type header preset to `multipart/form-data`. + +`FileList` object can be passed directly: + +```js +await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files) +``` + +All files will be sent with the same field names: `files[]`; diff --git a/posts/hi/notes.md b/posts/hi/notes.md new file mode 100644 index 00000000..7f54e84d --- /dev/null +++ b/posts/hi/notes.md @@ -0,0 +1,38 @@ +--- +title: 'Notes' +description: 'A couple more notes to round it off' +prev_title: 'URL-Encoding Bodies' +prev_link: '/docs/urlencoded' +--- + +## Semver + +Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes. + +## Promises + +axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises). +If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise). + +## TypeScript +axios includes [TypeScript](http://typescriptlang.org) definitions. +```typescript +import axios from 'axios'; +axios.get('/user?ID=12345'); +``` + +## Resources + +* [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) +* [Upgrade Guide](https://github.com/axios/axios/blob/v1.x/UPGRADE_GUIDE.md) +* [Ecosystem](https://github.com/axios/axios/blob/v1.x/ECOSYSTEM.md) +* [Contributing Guide](https://github.com/axios/axios/blob/v1.x/CONTRIBUTING.md) +* [Code of Conduct](https://github.com/axios/axios/blob/v1.x/CODE_OF_CONDUCT.md) + +## Credits + +axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular. + +## License + +[MIT](https://github.com/axios/axios/blob/v1.x/LICENSE) \ No newline at end of file diff --git a/posts/hi/post_example.md b/posts/hi/post_example.md new file mode 100644 index 00000000..61731b4f --- /dev/null +++ b/posts/hi/post_example.md @@ -0,0 +1,88 @@ +--- +title: 'POST Requests' +description: 'How to perform POST requests with Axios' +prev_title: 'Minimal Example' +prev_link: '/docs/example' +next_title: 'Axios API' +next_link: '/docs/api_intro' +--- + +## Performing a `POST` request + +### JSON + +```js +axios.post('/user', { + firstName: 'Fred', + lastName: 'Flintstone' + }) + .then(function (response) { + console.log(response); + }) + .catch(function (error) { + console.log(error); + }); +``` + +Performing multiple concurrent requests + +```js +function getUserAccount() { + return axios.get('/user/12345'); +} + +function getUserPermissions() { + return axios.get('/user/12345/permissions'); +} + +const [acct, perm] = await Promise.all([getUserAccount(), getUserPermissions()]); + +// OR + +Promise.all([getUserAccount(), getUserPermissions()]) + .then(function ([acct, perm]) { + // ... + }); +``` + +Post an HTML form as JSON + +```js +const {data} = await axios.post('/user', document.querySelector('#my-form'), { + headers: { + 'Content-Type': 'application/json' + } +}) +``` + +### Forms + +- Multipart (`multipart/form-data`) + +```js +const {data} = await axios.post('https://httpbin.org/post', { + firstName: 'Fred', + lastName: 'Flintstone', + orders: [1, 2, 3], + photo: document.querySelector('#fileInput').files + }, { + headers: { + 'Content-Type': 'multipart/form-data' + } + } +) +``` + +- URL encoded form (`application/x-www-form-urlencoded`) + +```js +const {data} = await axios.post('https://httpbin.org/post', { + firstName: 'Fred', + lastName: 'Flintstone', + orders: [1, 2, 3] + }, { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } +}) +``` diff --git a/posts/hi/req_config.md b/posts/hi/req_config.md new file mode 100644 index 00000000..db6702e3 --- /dev/null +++ b/posts/hi/req_config.md @@ -0,0 +1,257 @@ +--- +title: 'Request Config' +prev_title: 'The Axios Instance' +prev_link: '/docs/instance' +next_title: 'Response Schema' +next_link: '/docs/res_schema' +--- + + +These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified. + +```js +{ + // `url` is the server URL that will be used for the request + url: '/user', + + // `method` is the request method to be used when making the request + method: 'get', // default + + // `baseURL` will be prepended to `url` unless `url` is absolute. + // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs + // to methods of that instance. + baseURL: 'https://some-domain.com/api', + + // `allowAbsoluteUrls` determines whether or not absolute URLs will override a configured `baseUrl`. + // When set to true (default), absolute values for `url` will override `baseUrl`. + // When set to false, absolute values for `url` will always be prepended by `baseUrl`. + allowAbsoluteUrls: true, + + // `transformRequest` allows changes to the request data before it is sent to the server + // This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE' + // The last function in the array must return a string or an instance of Buffer, ArrayBuffer, + // FormData or Stream + // You may modify the headers object. + transformRequest: [function (data, headers) { + // Do whatever you want to transform the data + + return data; + }], + + // `transformResponse` allows changes to the response data to be made before + // it is passed to then/catch + transformResponse: [function (data) { + // Do whatever you want to transform the data + + return data; + }], + + // `headers` are custom headers to be sent + headers: {'X-Requested-With': 'XMLHttpRequest'}, + + // `params` are the URL parameters to be sent with the request + // Must be a plain object or a URLSearchParams object + // NOTE: params that are null or undefined are not rendered in the URL. + params: { + ID: 12345 + }, + + // `paramsSerializer` is an optional config in charge of serializing `params` + paramsSerializer: { + encode?: (param: string): string => { /* Do custom ops here and return transformed string */ }, // custom encoder function; sends Key/Values in an iterative fashion + serialize?: (params: Record, options?: ParamsSerializerOptions ), // mimic pre 1.x behavior and send entire params object to a custom serializer func. Allows consumer to control how params are serialized. + indexes: false // array indexes format (null - no brackets, false (default) - empty brackets, true - brackets with indexes) + }, + + // `data` is the data to be sent as the request body + // Only applicable for request methods 'PUT', 'POST', 'DELETE', and 'PATCH' + // When no `transformRequest` is set, must be of one of the following types: + // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams + // - Browser only: FormData, File, Blob + // - Node only: Stream, Buffer + data: { + firstName: 'Fred' + }, + + // syntax alternative to send data into the body + // method post + // only the value is sent, not the key + data: 'Country=Brasil&City=Belo Horizonte', + + // `timeout` specifies the number of milliseconds before the request times out. + // If the request takes longer than `timeout`, the request will be aborted. + timeout: 1000, // default is `0` (no timeout) + + // `withCredentials` indicates whether or not cross-site Access-Control requests + // should be made using credentials + withCredentials: false, // default + + // `adapter` allows custom handling of requests which makes testing easier. + // Return a promise and supply a valid response (see lib/adapters/README.md). + adapter: function (config) { + /* ... */ + }, + + // `auth` indicates that HTTP Basic auth should be used, and supplies credentials. + // This will set an `Authorization` header, overwriting any existing + // `Authorization` custom headers you have set using `headers`. + // Please note that only HTTP Basic auth is configurable through this parameter. + // For Bearer tokens and such, use `Authorization` custom headers instead. + auth: { + username: 'janedoe', + password: 's00pers3cret' + }, + + // `responseType` indicates the type of data that the server will respond with + // options are: 'arraybuffer', 'document', 'json', 'text', 'stream' + // browser only: 'blob' + responseType: 'json', // default + + // `responseEncoding` indicates encoding to use for decoding responses (Node.js only) + // Note: Ignored for `responseType` of 'stream' or client-side requests + responseEncoding: 'utf8', // default + + // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token + xsrfCookieName: 'XSRF-TOKEN', // default + + // `xsrfHeaderName` is the name of the http header that carries the xsrf token value + xsrfHeaderName: 'X-XSRF-TOKEN', // default + + // `onUploadProgress` allows handling of progress events for uploads + // browser only + onUploadProgress: function (progressEvent) { + // Do whatever you want with the native progress event + }, + + // `onDownloadProgress` allows handling of progress events for downloads + // browser only + onDownloadProgress: function (progressEvent) { + // Do whatever you want with the native progress event + }, + + // `maxContentLength` defines the max size of the http response content in bytes allowed in node.js + maxContentLength: 2000, + + // `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed + maxBodyLength: 2000, + + // `validateStatus` defines whether to resolve or reject the promise for a given + // HTTP response status code. If `validateStatus` returns `true` (or is set to `null` + // or `undefined`), the promise will be resolved; otherwise, the promise will be + // rejected. + validateStatus: function (status) { + return status >= 200 && status < 300; // default + }, + + // `maxRedirects` defines the maximum number of redirects to follow in node.js. + // If set to 0, no redirects will be followed. + maxRedirects: 21, // default + + // `beforeRedirect` defines a function that will be called before redirect. + // Use this to adjust the request options upon redirecting, + // to inspect the latest response headers, + // or to cancel the request by throwing an error + // If maxRedirects is set to 0, `beforeRedirect` is not used. + beforeRedirect: (options, { headers }) => { + if (options.hostname === "example.com") { + options.auth = "user:password"; + } + }, + + // `socketPath` defines a UNIX Socket to be used in node.js. + // e.g. '/var/run/docker.sock' to send requests to the docker daemon. + // Only either `socketPath` or `proxy` can be specified. + // If both are specified, `socketPath` is used. + socketPath: null, // default + + // `transport` determines the transport method that will be used to make the request. If defined, it will be used. Otherwise, if `maxRedirects` is 0, the default `http` or `https` library will be used, depending on the protocol specified in `protocol`. Otherwise, the `httpFollow` or `httpsFollow` library will be used, again depending on the protocol, which can handle redirects. + transport: undefined, // default + + // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http + // and https requests, respectively, in node.js. This allows options to be added like + // `keepAlive` that are not enabled by default before Node.js v19.0.0. After Node.js + // v19.0.0, you no longer need to customize the agent to enable `keepAlive` because + // `http.globalAgent` has `keepAlive` enabled by default. + httpAgent: new http.Agent({ keepAlive: true }), + httpsAgent: new https.Agent({ keepAlive: true }), + + // `proxy` defines the hostname, port, and protocol of the proxy server. + // You can also define your proxy using the conventional `http_proxy` and + // `https_proxy` environment variables. If you are using environment variables + // for your proxy configuration, you can also define a `no_proxy` environment + // variable as a comma-separated list of domains that should not be proxied. + // Use `false` to disable proxies, ignoring environment variables. + // Disable if supplying a custom httpAgent/httpsAgent to manage proxying requests. + // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and + // supplies credentials. + // This will set an `Proxy-Authorization` header, overwriting any existing + // `Proxy-Authorization` custom headers you have set using `headers`. + // If the proxy server uses HTTPS, then you must set the protocol to `https`. + proxy: { + protocol: 'https', + host: '127.0.0.1', + port: 9000, + auth: { + username: 'mikeymike', + password: 'rapunz3l' + } + }, + + // `signal` and instance of AbortController can be used to cancel the request + signal: new AbortController().signal, + + // (Deprecated) `cancelToken` specifies a cancel token that can also be used to cancel the request + // (see Cancellation section below for details) + cancelToken: new CancelToken(function (cancel) { + }), + + // an alternative way to cancel Axios requests using AbortController + signal: new AbortController().signal, + + // `decompress` indicates whether or not the response body should be decompressed + // automatically. If set to `true` will also remove the 'content-encoding' header + // from the responses objects of all decompressed responses + // - Node only (XHR cannot turn off decompression) + decompress: true // default + + // `insecureHTTPParser` boolean. + // Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers. + // This may allow interoperability with non-conformant HTTP implementations. + // Using the insecure parser should be avoided. + // see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback + // see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-none + insecureHTTPParser: undefined // default + + // transitional options for backward compatibility that may be removed in the newer versions + transitional: { + // silent JSON parsing mode + // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour) + // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json') + silentJSONParsing: true, // default value for the current Axios version + + // try to parse the response string as JSON even if `responseType` is not 'json' + forcedJSONParsing: true, + + // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts + clarifyTimeoutError: false, + }, + + env: { + // The FormData class to be used to automatically serialize the payload into a FormData object + FormData: window?.FormData || global?.FormData + }, + + formSerializer: { + visitor: (value, key, path, helpers) => {}; // custom visitor function to serialize form values + dots: boolean; // use dots instead of brackets format + metaTokens: boolean; // keep special endings like {} in parameter key + indexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes + }, + + // http adapter only (node.js) + maxRate: [ + 100 * 1024, // 100KB/s upload limit, + 100 * 1024 // 100KB/s download limit + ] +} +``` diff --git a/posts/hi/res_schema.md b/posts/hi/res_schema.md new file mode 100644 index 00000000..d33eb3ef --- /dev/null +++ b/posts/hi/res_schema.md @@ -0,0 +1,52 @@ +--- +title: 'Response Schema' +prev_title: 'Request Config' +prev_link: '/docs/req_config' +next_title: 'Config Defaults' +next_link: '/docs/config_defaults' +--- + +The response for a request contains the following information. + +```js +{ + // `data` is the response that was provided by the server + data: {}, + + // `status` is the HTTP status code from the server response + status: 200, + + // `statusText` is the HTTP status message from the server response + // As of HTTP/2 status text is blank or unsupported. + // (HTTP/2 RFC: https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2.4) + statusText: 'OK', + + // `headers` the HTTP headers that the server responded with + // All header names are lower cased and can be accessed using the bracket notation. + // Example: `response.headers['content-type']` + headers: {}, + + // `config` is the config that was provided to `axios` for the request + config: {}, + + // `request` is the request that generated this response + // It is the last ClientRequest instance in node.js (in redirects) + // and an XMLHttpRequest instance in the browser + request: {} +} +``` + +When using `then`, you will receive the response as follows: + +```js +axios.get('/user/12345') + .then(function (response) { + console.log(response.data); + console.log(response.status); + console.log(response.statusText); + console.log(response.headers); + console.log(response.config); + }); +``` + +When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as second parameter of `then`, the response will be available through the `error` object as explained in the [Handling Errors](/docs/handling_errors) section. diff --git a/posts/hi/sponsor.md b/posts/hi/sponsor.md new file mode 100644 index 00000000..07f07ef1 --- /dev/null +++ b/posts/hi/sponsor.md @@ -0,0 +1,90 @@ +--- +title: 'Sponsoring Axios' +--- + +Thank you for considering supporting our project. Your donation will be used to maintain and develop Axios. + +As a benefit to our major sponsors, we provide the opportunity to add your logo and brief +information to our website and/or [Readme.md](https://github.com/axios/axios) depending on the tier of support you choose. +This process is fully automated if you donate through [OpenCollective.com](https://opencollective.com/axios/contribute), +so your logo will be added within 24 hours. + +Your logo can be placed: +- in the carousel on the main page +- in carousels on each page of the documentation +- at the top of [Readme.md](https://github.com/axios/axios) in our repo + +Place in the carousel depends on: +- newness of the sponsor (new sponsors temporarily receive higher places) +- selected support tier +- total amount of money donated +- consistency of donations + +If you donate through [GitHub](https://github.com/sponsors/axios), you will need to contact us later if you want your logo to be promoted according +to our support tiers. + +### Tiers + +See tiers list on [Open Collective](https://opencollective.com/axios/contribute) + +| | Bronze | Silver | Gold | Platinum | +|---------------------------------------------|:----------:|:-----------:|:-----------:|:----------------:| +| Main page | small logo | medium logo | large logo | extra large logo | +| Docs pages | | | medium logo | large logo | +| [Readme.md](https://github.com/axios/axios) | | | small logo | medium logo | +| Data merging from sponsor's GitHub repo | | + | + | + | +| Links block in tooltip* | | | + | + | +| Embedded Youtube video in tooltip* | | | + | + | +| Max description length in Readme.md (chars) | | | 100 | 150 | + +> Note: +> The extra links block and video can only be set via `sponsors.json` + +### Backer tier + +You can create a custom tier, in which case you will get the benefits of the highest existing tier whose price +is covered by your donation. The extra donation amount above the existing tier will be taken into account +when sorting sponsors in a carousel. + +### Sponsor logo + +Your logo will be downloaded to our server, optimized, trimmed empty borders and resized with preservation of proportions. +If the width of the logo is significantly greater than its height, then the text caption will be hidden, +and the logo will take up all the available space. The maximum logo height is the same for all tiers. + +### Description + +If the description is not provided, we will try to parse it from the sponsor's site meta tags. + +### GitHub + +If you have set up your GitHub profile in your Open Collective profile, +you can create a special repository called `axios-sponsor` with `sponsor.json` in its root to manage your sponsor profile data. + +The data from this file will be merged with your Open Collective profile which allows you to provide some extra info for advertising. + +`sponsor.json` has the following structure (each field is optional): + +```json + { + "displayName": "Umbrella Corporation", + "targetLink": "https://umbrellacorp.com/", + "alt": "Umbrella Corporation", + "image": "https://fake.com/logo.png", + "image_dark": "https://fake.com/logo_dark.png", + "description": "The Umbrella Corporation is a pharmaceutical company", + "website": "https://google.com/", + "github": "https://github.com/fakeGitHib", + "icon": "https://fake.com/icon.png", + "video": "https://www.youtube.com/embed/isosE4Bowh0", + "twitter": "https://x.com/profile", + "showCaption": true, + "crown": false, + "hide": false, + "links": { + "link1": "https://google.com/", + "link2": "https://google.com/" + } + } +``` +Every 24 hour our backend will pull this data when update sponsors list on the website. diff --git a/posts/hi/translating.md b/posts/hi/translating.md new file mode 100644 index 00000000..f0f52d25 --- /dev/null +++ b/posts/hi/translating.md @@ -0,0 +1,47 @@ +--- +title: 'दस्तावेज़ों का अनुवाद करना' +--- + +Axios को ज़्यादा से ज़्यादा लोगों तक पहुँचाने के लिए, यह ज़रूरी है कि ये दस्तावेज़ सभी भाषाओं में पढ़े जा सकें। हम उन सभी लोगों का हमेशा आभार व्यक्त करते हैं जो +दस्तावेज़ के अनुवाद में मदद करना चाहते हैं। यह मार्गदर्शिका इस दस्तावेज़ में अनुवाद जोड़ने के निर्देश प्रदान करती है। + +## संरचना + +प्रत्येक अनुवाद एक कॉन्फ़िगरेशन फ़ाइल, `{language-shortcut}.lang.js` (उदाहरण के लिए, `en.lang.js` या `de.lang.js`) और `posts/{language-shortcut}/*.md` (उदाहरण के लिए `posts/en` या `posts/de`) में अनुवादित दस्तावेज़ फ़ाइलों से बना होता है। `{language-shortcut}` को आपकी भाषा के [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) दो-अक्षर वाले कोड से बदला जाना चाहिए। + +## अपनी भाषा में बनाना + +- `en.lang.js` को कॉपी करें। +- इसका नाम बदलकर `{language-shortcut}.lang.js` कर दें। +- `display` को अपनी भाषा के नाम से बदलें, अपनी भाषा में। उदाहरण के लिए, यदि आप जर्मन का अनुवाद कर रहे हैं, तो "German" के बजाय "Deutsch" लिखें। +- prefix को `/{language-shortcut}/` से बदलें। +- `p` और `t` फ़ील्ड में वैल्यूज का अनुवाद करें। +- साइडबार में `text` लेबल वाले सभी गुणों का अनुवाद करें। **नोट:** इस दस्तावेज़ के नवीनतम संस्करण के बाद से, साइडबार में लिंक को अब अपडेट करने की आवश्यकता नहीं है। + +### नई भाषा को पंजीकृत करना + +अपनी भाषा बनाने और कॉन्फ़िगरेशन फ़ाइल में वाक्यांशों और लिंक का अनुवाद करने के बाद, आपको इसे रूट कॉन्फ़िगरेशन में पंजीकृत करना होगा। ऐसा करने के लिए, `inert.config.js` खोलें और ऊपर की ओर निम्न पंक्ति जोड़ें: + +```js +const {language-shortcut}Config = require('./{language-shortcut}.config.js'); +``` + +बेशक, `{language-shortcut}` को सही [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) कोड (वेरिएबल नाम में भी!) से बदलना याद रखें। + +अब, `langs` स्थिरांक देखें। अगर यह स्थिरांक आपके `require` कथन के ऊपर स्थित है, तो अपने `require` कथन को उसके ऊपर ले जाएँ। `langs` सूची में, निम्न ऑब्जेक्ट जोड़ें: + +```js +const langs = [ +... +{ +name: 'कोई ऐसा नाम जो आपकी भाषा को विशिष्ट रूप से पहचानता हो, उदाहरण के लिए "English" या "German"', +prefix: "कॉन्फ़िगरेशन फ़ाइल में दिया गया prefix", +config: {language-shortcut}Config // वह कॉन्फ़िगरेशन ऑब्जेक्ट जिसे आपने पहले आयात किया था +} +... +]; +``` + +अब, आप फ़ाइलों का अनुवाद शुरू कर सकते हैं। `posts/en` फ़ोल्डर को एक नए फ़ोल्डर `posts/{language-shortcut}` में कॉपी करें और सभी फ़ाइलों का अनुवाद करें (फ़ाइल नामों का अनुवाद न करें, बिल्कुल)। + +यदि आपको कोई समस्या आती है, तो बेझिझक [समस्या बनाएँ](https://github.com/axios/axios-docs/issues/new/choose) करें। \ No newline at end of file diff --git a/posts/hi/urlencoded.md b/posts/hi/urlencoded.md new file mode 100644 index 00000000..1c2b8c66 --- /dev/null +++ b/posts/hi/urlencoded.md @@ -0,0 +1,119 @@ +--- +title: 'URL-Encoding Bodies' +prev_title: 'Cancellation' +prev_link: '/docs/cancellation' +next_title: 'Multipart Bodies' +next_link: '/docs/multipart' +--- + +By default, axios serializes JavaScript objects to `JSON`. To send data in the `application/x-www-form-urlencoded` format instead, you can use one of the following approaches. + +### Browser + +In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows: + +```js +const params = new URLSearchParams(); +params.append('param1', 'value1'); +params.append('param2', 'value2'); +axios.post('/foo', params); +``` + +> Note that `URLSearchParams` is not supported by all browsers (see [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment). + +Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library: + +```js +const qs = require('qs'); +axios.post('/foo', qs.stringify({ 'bar': 123 })); +``` + +Or in another way (ES6), + +```js +import qs from 'qs'; +const data = { 'bar': 123 }; +const options = { + method: 'POST', + headers: { 'content-type': 'application/x-www-form-urlencoded' }, + data: qs.stringify(data), + url, +}; +axios(options); +``` + +### Node.js + +#### Query string + +In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: + +```js +const querystring = require('querystring'); +axios.post('http://something.com/', querystring.stringify({ foo: 'bar' })); +``` + +or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows: + +```js +const url = require('url'); +const params = new url.URLSearchParams({ foo: 'bar' }); +axios.post('http://something.com/', params.toString()); +``` + +You can also use the [`qs`](https://github.com/ljharb/qs) library. + +> Note: The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665). + +### 🆕 Automatic serialization + +Axios will automatically serialize the data object to urlencoded format if the `content-type` header is set to `application/x-www-form-urlencoded`. + +This works both in the browser and in `node.js`: + +```js +const data = { + x: 1, + arr: [1, 2, 3], + arr2: [1, [2], 3], + users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], +}; + +await axios.post('https://postman-echo.com/post', data, + {headers: {'content-type': 'application/x-www-form-urlencoded'}} +); +``` + +The server will handle it as + +```js + { + x: '1', + 'arr[]': [ '1', '2', '3' ], + 'arr2[0]': '1', + 'arr2[1][0]': '2', + 'arr2[2]': '3', + 'arr3[]': [ '1', '2', '3' ], + 'users[0][name]': 'Peter', + 'users[0][surname]': 'griffin', + 'users[1][name]': 'Thomas', + 'users[1][surname]': 'Anderson' + } +```` + +If your server framework's request body parser (like `body-parser` of `express.js`) supports nested objects decoding, +you will automatically receive the same server object that you submitted. + +Echo server example (`express.js`) : + +```js + var app = express(); + + app.use(bodyParser.urlencoded({ extended: true })); // support url-encoded bodies + + app.post('/', function (req, res, next) { + res.send(JSON.stringify(req.body)); + }); + + server = app.listen(3000); +``` From 96def445854b8bbff4d043a5af897a07462c29cf Mon Sep 17 00:00:00 2001 From: Arun Kaushik <46048646+incrediblenura@users.noreply.github.com> Date: Sun, 9 Nov 2025 23:55:22 +0530 Subject: [PATCH 4/9] Add files via upload --- hi.lang.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hi.lang.js b/hi.lang.js index 5460a041..2726f705 100644 --- a/hi.lang.js +++ b/hi.lang.js @@ -27,7 +27,7 @@ module.exports = { "Contribute": 'योगदान करें', "Source on GitHub": 'GitHub पर स्रोत', "Issues": 'समस्याऐं', - "Pull Requests": 'undefined', + "Pull Requests": 'Pull Requests', "Code of Conduct": 'Code of Conduct', "Fork on GitHub": "GitHub में फोर्क करें", "Fork the Website": "Website फोर्क करें", From 7c70f90c2f1b80aa0452d2226e2c1a6a199f569b Mon Sep 17 00:00:00 2001 From: Arun Kaushik <46048646+incrediblenura@users.noreply.github.com> Date: Sun, 9 Nov 2025 23:59:07 +0530 Subject: [PATCH 5/9] Delete posts/hi/index.md --- posts/hi/index.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 posts/hi/index.md diff --git a/posts/hi/index.md b/posts/hi/index.md deleted file mode 100644 index 76f177f1..00000000 --- a/posts/hi/index.md +++ /dev/null @@ -1 +0,0 @@ -# Hi From 1c1357cdf3a0694e24c639fa38c00a1c8f058a70 Mon Sep 17 00:00:00 2001 From: Arun Kaushik <46048646+incrediblenura@users.noreply.github.com> Date: Mon, 10 Nov 2025 00:00:30 +0530 Subject: [PATCH 6/9] Translated All Markdown Files --- posts/hi/api_intro.md | 54 +++--- posts/hi/cancellation.md | 116 ++++++------ posts/hi/config_defaults.md | 38 ++-- posts/hi/example.md | 89 +++++---- posts/hi/handling_errors.md | 78 ++++---- posts/hi/instance.md | 42 ++--- posts/hi/interceptors.md | 60 +++--- posts/hi/intro.md | 76 ++++---- posts/hi/multipart.md | 144 +++++++------- posts/hi/notes.md | 39 ++-- posts/hi/post_example.md | 98 +++++----- posts/hi/req_config.md | 361 +++++++++++------------------------- posts/hi/res_schema.md | 62 +++---- posts/hi/sponsor.md | 129 +++++++------ posts/hi/urlencoded.md | 106 +++++------ 15 files changed, 676 insertions(+), 816 deletions(-) diff --git a/posts/hi/api_intro.md b/posts/hi/api_intro.md index e0c4e7b4..3614e34a 100644 --- a/posts/hi/api_intro.md +++ b/posts/hi/api_intro.md @@ -1,50 +1,50 @@ --- -title: 'Axios API' -description: 'The Axios API Reference' -prev_title: 'POST Requests' -prev_link: '/docs/post_example' -next_title: 'The Axios Instance' -next_link: '/docs/instance' +शीर्षक: 'एक्सियोस एपीआई' +विवरण: 'एक्सियोस एपीआई संदर्भ' +पिछला_शीर्षक: 'पोस्ट अनुरोध' +पिछला_लिंक: '/docs/post_example' +अगला_शीर्षक: 'एक्सियोस इंस्टेंस' +अगला_लिंक: '/docs/instance' --- -Requests can be made by passing the relevant config to `axios`. +संबंधित कॉन्फ़िगरेशन को `axios` में पास करके अनुरोध किए जा सकते हैं। ##### axios(config) ```js -// Send a POST request +// एक पोस्ट अनुरोध भेजें axios({ - method: 'post', - url: '/user/12345', - data: { - firstName: 'Fred', - lastName: 'Flintstone' - } +method: 'post', +url: '/user/12345', +data: { +firstName: 'Fred', +lastName: 'Flintstone' +} }); ``` ```js -// GET request for remote image in node.js +// node.js में दूरस्थ छवि के लिए GET अनुरोध axios({ - method: 'get', - url: 'http://bit.ly/2mTM3nY', - responseType: 'stream' +method: 'get', +url: 'http://bit.ly/2mTM3nY', +responseType: 'stream' }) - .then(function (response) { - response.data.pipe(fs.createWriteStream('ada_lovelace.jpg')) - }); +.then(function (response) { +response.data.pipe(fs.createWriteStream('ada_lovelace.jpg')) +}); ``` -##### axios(url[, config]) +#### axios(url[, config]) ```js -// Send a GET request (default method) +// एक GET अनुरोध भेजें (डिफ़ॉल्ट विधि) axios('/user/12345'); ``` -### Request method aliases +### अनुरोध विधि उपनाम -For convenience aliases have been provided for all supported request methods. +सुविधा के लिए सभी समर्थित अनुरोध विधियों के लिए उपनाम प्रदान किए गए हैं। ##### axios.request(config) ##### axios.get(url[, config]) @@ -56,6 +56,4 @@ For convenience aliases have been provided for all supported request methods. ##### axios.patch(url[, data[, config]]) ##### axios.postForm(url[, data[, config]]) ##### axios.putForm(url[, data[, config]]) -##### axios.patchForm(url[, data[, config]]) - -> NOTE: When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config. +##### axios.patchForm(url[, data[, config]]) उपनाम विधियों `url`, `method`, और `data` का उपयोग करते समय गुणों को कॉन्फ़िगरेशन में निर्दिष्ट करने की आवश्यकता नहीं होती है। \ No newline at end of file diff --git a/posts/hi/cancellation.md b/posts/hi/cancellation.md index 1b0f7e1b..9cae6055 100644 --- a/posts/hi/cancellation.md +++ b/posts/hi/cancellation.md @@ -1,118 +1,118 @@ --- -title: 'Cancellation' -prev_title: 'Handling Errors' +शीर्षक: 'रद्दीकरण' +prev_title: 'त्रुटियों का प्रबंधन' prev_link: '/docs/handling_errors' -next_title: 'URL-Encoding Bodies' +next_title: 'URL-एन्कोडिंग निकाय' next_link: '/docs/urlencoded' --- -## Cancelling requests +## अनुरोध रद्द करना -Setting the `timeout` property in an axios call handles **response** related timeouts. +axios कॉल में `timeout` गुण सेट करने से **प्रतिक्रिया** से संबंधित टाइमआउट प्रबंधित होते हैं। -In some cases (e.g. network connection becomes unavailable) an axios call would benefit from cancelling the **connection** early. Without cancellation, the axios call can hang until the parent code/stack times out (might be a few minutes in a server-side applications). +कुछ मामलों में (जैसे नेटवर्क कनेक्शन अनुपलब्ध हो जाता है) axios कॉल को **कनेक्शन** को जल्दी रद्द करने से लाभ होगा। रद्दीकरण के बिना, axios कॉल तब तक रुकी रह सकती है जब तक कि पैरेंट कोड/स्टैक का समय समाप्त न हो जाए (सर्वर-साइड एप्लिकेशन में कुछ मिनट लग सकते हैं)। -To terminate an axios call you can use following methods: +एक्सियोस कॉल को समाप्त करने के लिए आप निम्नलिखित विधियों का उपयोग कर सकते हैं: - `signal` -- `cancelToken` (deprecated) +- `cancelToken` (अप्रचलित) -Combining `timeout` and cancellation method (e.g. `signal`) should cover **response** related timeouts AND **connection** related timeouts. +`timeout` और रद्दीकरण विधि (जैसे `signal`) को मिलाकर **प्रतिक्रिया** से संबंधित समयबाह्य और **कनेक्शन** से संबंधित समयबाह्य को कवर किया जाना चाहिए। ### `signal`: AbortController -Starting from `v0.22.0` Axios supports [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to cancel requests in fetch API way: +`v0.22.0` से शुरू होकर, एक्सियोस फ़ेच API तरीके से अनुरोधों को रद्द करने के लिए [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) का समर्थन करता है: ```js const controller = new AbortController(); axios.get('/foo/bar', { - signal: controller.signal +signal: controller.signal }).then(function(response) { - //... +//... }); -// cancel the request +// अनुरोध रद्द करें controller.abort() ``` -Example with a timeout using latest [`AbortSignal.timeout()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout) API [nodejs 17.3+]: +नवीनतम [`AbortSignal.timeout()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout) API [nodejs 17.3+] का उपयोग करके टाइमआउट वाला उदाहरण: ```js axios.get('/foo/bar', { - signal: AbortSignal.timeout(5000) //Aborts request after 5 seconds +signal: AbortSignal.timeout(5000) //5 सेकंड के बाद अनुरोध रद्द करता है }).then(function(response) { - //... +//... }); ``` -Example with a timeout helper function: +टाइमआउट सहायक फ़ंक्शन वाला उदाहरण: ```js function newAbortSignal(timeoutMs) { - const abortController = new AbortController(); - setTimeout(() => abortController.abort(), timeoutMs || 0); +const abortController = new AbortController(); +setTimeout(() => abortController.abort(), timeoutMs || 0); - return abortController.signal; +return abortController.signal; } axios.get('/foo/bar', { - signal: newAbortSignal(5000) //Aborts request after 5 seconds +signal: newAbortSignal(5000) //5 सेकंड के बाद अनुरोध निरस्त करता है }).then(function(response) { - //... +//... }); ``` ### CancelToken `deprecated` -You can also cancel a request using a *CancelToken*. +आप *CancelToken* का उपयोग करके भी अनुरोध रद्द कर सकते हैं। -> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises). +> Axios कैंसल टोकन API, वापस लिए गए [कैंसलेबल प्रॉमिस प्रस्ताव](https://github.com/tc39/proposal-cancelable-promises) पर आधारित है। -> This API is deprecated since `v0.22.0` and shouldn't be used in new projects +> यह API `v0.22.0` से बंद है और इसे नए प्रोजेक्ट में इस्तेमाल नहीं किया जाना चाहिए। -You can create a cancel token using the `CancelToken.source` factory as shown below: +आप `CancelToken.source` फ़ैक्टरी का उपयोग करके एक कैंसल टोकन बना सकते हैं, जैसा कि नीचे दिखाया गया है: ```js const CancelToken = axios.CancelToken; const source = CancelToken.source(); axios.get('/user/12345', { - cancelToken: source.token +cancelToken: source.token }).catch(function (thrown) { - if (axios.isCancel(thrown)) { - console.log('Request canceled', thrown.message); - } else { - // handle error - } +if (axios.isCancel(thrown)) { +console.log('अनुरोध रद्द', thrown.message); +} else { +// त्रुटि संभालें +} }); axios.post('/user/12345', { - name: 'new name' +name: 'नया नाम' }, { - cancelToken: source.token +cancelToken: source.token }) -// cancel the request (the message parameter is optional) -source.cancel('Operation canceled by the user.'); +// अनुरोध रद्द करें (संदेश पैरामीटर वैकल्पिक है) +source.cancel('उपयोगकर्ता द्वारा कार्रवाई रद्द कर दी गई।'); ``` -You can also create a cancel token by passing an executor function to the `CancelToken` constructor: +आप `CancelToken` कंस्ट्रक्टर में एक निष्पादक फ़ंक्शन पास करके एक रद्द टोकन भी बना सकते हैं: ```js const CancelToken = axios.CancelToken; let cancel; axios.get('/user/12345', { - cancelToken: new CancelToken(function executor(c) { - // An executor function receives a cancel function as a parameter - cancel = c; - }) +cancelToken: new CancelToken(function executor(c) { +// एक निष्पादक फ़ंक्शन एक पैरामीटर के रूप में एक रद्द फ़ंक्शन प्राप्त करता है +cancel = c; +}) }); -// cancel the request +// अनुरोध रद्द करें cancel(); ``` -> Note: you can cancel several requests with the same cancel token / signal. +> नोट: आप एक ही रद्द टोकन/सिग्नल से कई अनुरोध रद्द कर सकते हैं। -During the transition period, you can use both cancellation APIs, even for the same request: +संक्रमण अवधि के दौरान, आप एक ही अनुरोध के लिए भी, दोनों रद्दीकरण API का उपयोग कर सकते हैं: ```js const controller = new AbortController(); @@ -121,24 +121,24 @@ const CancelToken = axios.CancelToken; const source = CancelToken.source(); axios.get('/user/12345', { - cancelToken: source.token, - signal: controller.signal +cancelToken: source.token, +signal: controller.signal }).catch(function (thrown) { - if (axios.isCancel(thrown)) { - console.log('Request canceled', thrown.message); - } else { - // handle error - } +if (axios.isCancel(thrown)) { +console.log('अनुरोध रद्द', thrown.message); +} else { +// त्रुटि हैंडल करें +} }); axios.post('/user/12345', { - name: 'new name' +name: 'नया नाम' }, { - cancelToken: source.token +cancelToken: source.token }) -// cancel the request (the message parameter is optional) -source.cancel('Operation canceled by the user.'); -// OR -controller.abort(); // the message parameter is not supported -``` +// अनुरोध रद्द करें (संदेश पैरामीटर वैकल्पिक है) +source.cancel('उपयोगकर्ता द्वारा कार्रवाई रद्द कर दी गई।'); +// या +controller.abort(); // संदेश पैरामीटर समर्थित नहीं है +``` \ No newline at end of file diff --git a/posts/hi/config_defaults.md b/posts/hi/config_defaults.md index fc16a5aa..edea1348 100644 --- a/posts/hi/config_defaults.md +++ b/posts/hi/config_defaults.md @@ -1,16 +1,16 @@ --- -title: 'Config Defaults' -prev_title: 'Response Schema' +शीर्षक: 'कॉन्फ़िगरेशन डिफ़ॉल्ट' +prev_title: 'प्रतिक्रिया स्कीमा' prev_link: '/docs/res_schema' -next_title: 'Interceptors' +next_title: 'इंटरसेप्टर' next_link: '/docs/interceptors' --- -## Config Defaults +## कॉन्फ़िगरेशन डिफ़ॉल्ट -You can specify config defaults that will be applied to every request. +आप कॉन्फ़िगरेशन डिफ़ॉल्ट निर्दिष्ट कर सकते हैं जो प्रत्येक अनुरोध पर लागू होंगे। -### Global axios defaults +### वैश्विक axios डिफ़ॉल्ट ```js axios.defaults.baseURL = 'https://api.example.com'; @@ -18,33 +18,33 @@ axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; ``` -### Custom instance defaults +### कस्टम इंस्टेंस डिफ़ॉल्ट ```js -// Set config defaults when creating the instance +// इंस्टेंस बनाते समय कॉन्फ़िगरेशन डिफ़ॉल्ट सेट करें const instance = axios.create({ - baseURL: 'https://api.example.com' +baseURL: 'https://api.example.com' }); -// Alter defaults after instance has been created +/ इंस्टेंस बनने के बाद डिफ़ॉल्ट बदलें instance.defaults.headers.common['Authorization'] = AUTH_TOKEN; ``` -### Config order of precedence +### कॉन्फ़िगरेशन वरीयता क्रम -Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults/index.js](https://github.com/axios/axios/blob/v1.x/lib/defaults/index.js), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. +कॉन्फ़िगरेशन को वरीयता क्रम के साथ मर्ज किया जाएगा। यह क्रम [lib/defaults/index.js](https://github.com/axios/axios/blob/v1.x/lib/defaults/index.js) में पाए जाने वाले लाइब्रेरी डिफ़ॉल्ट के अनुसार होगा, फिर इंस्टेंस की `defaults` प्रॉपर्टी, और अंत में अनुरोध के लिए `config` तर्क। बाद वाले को पहले वाले पर वरीयता दी जाएगी। यहाँ एक उदाहरण दिया गया है। ```js -// Create an instance using the config defaults provided by the library -// At this point the timeout config value is `0` as is the default for the library +// लाइब्रेरी द्वारा प्रदान किए गए कॉन्फ़िगरेशन डिफ़ॉल्ट का उपयोग करके एक इंस्टेंस बनाएँ +// इस समय टाइमआउट कॉन्फ़िगरेशन मान `0` है, जैसा कि लाइब्रेरी के लिए डिफ़ॉल्ट है const instance = axios.create(); -// Override timeout default for the library -// Now all requests using this instance will wait 2.5 seconds before timing out +/ लाइब्रेरी के लिए टाइमआउट डिफ़ॉल्ट को ओवरराइड करें +// अब इस इंस्टेंस का उपयोग करने वाले सभी अनुरोध टाइमआउट से पहले 2.5 सेकंड प्रतीक्षा करेंगे instance.defaults.timeout = 2500; -// Override timeout for this request as it's known to take a long time +/ इस अनुरोध के लिए टाइमआउट ओवरराइड करें क्योंकि यह ज्ञात है कि इसमें लंबा समय लगता है instance.get('/longRequest', { - timeout: 5000 +timeout: 5000 }); -``` +``` \ No newline at end of file diff --git a/posts/hi/example.md b/posts/hi/example.md index 80019abc..cfde31d3 100644 --- a/posts/hi/example.md +++ b/posts/hi/example.md @@ -1,68 +1,67 @@ --- -title: 'Minimal Example' -description: 'A little example of using axios' -prev_title: 'Introduction' +शीर्षक: 'न्यूनतम उदाहरण' +विवरण: 'axios के उपयोग का एक छोटा सा उदाहरण' +prev_title: 'परिचय' prev_link: '/docs/intro' -next_title: 'POST Requests' +next_title: 'POST अनुरोध' next_link: '/docs/post_example' --- -## note: CommonJS usage -In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach: +## नोट: CommonJS उपयोग +`require()` के साथ CommonJS आयातों का उपयोग करते समय TypeScript टाइपिंग (intellisense / स्वतः पूर्ण के लिए) प्राप्त करने के लिए, निम्नलिखित विधि का उपयोग करें: ```js const axios = require('axios').default; -// axios. will now provide autocomplete and parameter typings +// axios. अब स्वतः पूर्ण और पैरामीटर टाइपिंग प्रदान करेगा ``` -# Example +# उदाहरण -Performing a `GET` request +`GET` अनुरोध निष्पादित करना ```js const axios = require('axios'); -// Make a request for a user with a given ID +// किसी दिए गए आईडी वाले उपयोगकर्ता के लिए अनुरोध करें axios.get('/user?ID=12345') - .then(function (response) { - // handle success - console.log(response); - }) - .catch(function (error) { - // handle error - console.log(error); - }) - .finally(function () { - // always executed - }); +.then(function (response) { +// सफलता को संभालें +console.log(response); +}) +.catch(function (error) { +// त्रुटि को संभालें +console.log(error); +}) +.finally(function () { +// हमेशा निष्पादित +}); -// Optionally the request above could also be done as +// वैकल्पिक रूप से, उपरोक्त अनुरोध इस प्रकार भी किया जा सकता है axios.get('/user', { - params: { - ID: 12345 - } - }) - .then(function (response) { - console.log(response); - }) - .catch(function (error) { - console.log(error); - }) - .finally(function () { - // always executed - }); +पैरामीटर: { +ID: 12345 +} +}) +.then(function (response) { +console.log(response); +}) +.catch(function (error) { +console.log(error); +}) +.finally(function () { +// हमेशा निष्पादित +}); -// Want to use async/await? Add the `async` keyword to your outer function/method. -async function getUser() { - try { - const response = await axios.get('/user?ID=12345'); - console.log(response); - } catch (error) { - console.error(error); - } +// async/await का उपयोग करना चाहते हैं? अपने बाहरी फ़ंक्शन/विधि में `async` कीवर्ड जोड़ें। +async फ़ंक्शन getUser() { +try { +const response = await axios.get('/user?ID=12345'); +console.log(response); +} catch (error) { +console.error(error); +} } ``` -> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet -> Explorer and older browsers, so use with caution. \ No newline at end of file +> **नोट:** `async/await` ECMAScript 2017 का हिस्सा है और इंटरनेट एक्सप्लोरर और पुराने ब्राउज़र में समर्थित नहीं है, इसलिए सावधानी से उपयोग करें। \ No newline at end of file diff --git a/posts/hi/handling_errors.md b/posts/hi/handling_errors.md index 48683e5b..de3582d6 100644 --- a/posts/hi/handling_errors.md +++ b/posts/hi/handling_errors.md @@ -1,55 +1,55 @@ --- -title: 'Handling Errors' -prev_title: 'Interceptors' -prev_link: '/docs/interceptors' -next_title: 'Cancellation' -next_link: '/docs/cancellation' +शीर्षक: 'त्रुटियों का प्रबंधन' +पिछला_शीर्षक: 'इंटरसेप्टर' +पिछला_लिंक: '/docs/interceptors' +अगला_शीर्षक: 'रद्दीकरण' +अगला_लिंक: '/docs/रद्दीकरण' --- -The general structure of axios errors is as follows: -- **message** - A quick summary of the error message and the status it failed with. -- **name** - This defines where the error originated from. For axios, it will always be an 'AxiosError'. -- **stack** - Provides the stack trace of the error. -- **config** - An axios config object with specific instance configurations defined by the user from when the request was made. -- **code** - Represents an axios identified error. The table below lists out specific definitions for internal axios error. -- **status** - HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings. +एक्सियोस त्रुटियों की सामान्य संरचना इस प्रकार है: +- **संदेश** - त्रुटि संदेश और उसकी विफलता की स्थिति का एक संक्षिप्त सारांश। +- **नाम** - यह परिभाषित करता है कि त्रुटि कहाँ से उत्पन्न हुई। एक्सियोस के लिए, यह हमेशा एक 'एक्सियोस त्रुटि' होगी। +- **स्टैक** - त्रुटि का स्टैक ट्रेस प्रदान करता है। +- **कॉन्फ़िगरेशन** - एक एक्सियोस कॉन्फ़िगरेशन ऑब्जेक्ट जिसमें अनुरोध किए जाने के समय से उपयोगकर्ता द्वारा परिभाषित विशिष्ट इंस्टेंस कॉन्फ़िगरेशन होते हैं। +- **कोड** - एक्सियोस द्वारा पहचानी गई त्रुटि को दर्शाता है। नीचे दी गई तालिका आंतरिक एक्सियोस त्रुटि की विशिष्ट परिभाषाओं को सूचीबद्ध करती है। +- **स्थिति** - HTTP प्रतिक्रिया स्थिति कोड। सामान्य HTTP प्रतिक्रिया स्थिति कोड अर्थों के लिए [यहाँ](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) देखें। ```js axios.get('/user/12345') - .catch(function (error) { - if (error.response) { - // The request was made and the server responded with a status code - // that falls out of the range of 2xx - console.log(error.response.data); - console.log(error.response.status); - console.log(error.response.headers); - } else if (error.request) { - // The request was made but no response was received - // `error.request` is an instance of XMLHttpRequest in the browser and an instance of - // http.ClientRequest in node.js - console.log(error.request); - } else { - // Something happened in setting up the request that triggered an Error - console.log('Error', error.message); - } - console.log(error.config); - }); +.catch(function (error) { +अगर (error.response) { +// अनुरोध किया गया और सर्वर ने एक स्थिति कोड के साथ प्रतिक्रिया दी +/जो 2xx की सीमा से बाहर है +console.log(error.response.data); +console.log(error.response.status); +console.log(error.response.headers); +} वरना अगर (error.request) { +// अनुरोध किया गया लेकिन कोई प्रतिक्रिया नहीं मिली +/`error.request` ब्राउज़र में XMLHttpRequest का एक उदाहरण है और +/ node.js में http.ClientRequest का एक उदाहरण है +console.log(error.request); +} वरना { +// अनुरोध सेट करते समय कुछ ऐसा हुआ जिससे एक त्रुटि उत्पन्न हुई +console.log('Error', error.message); +} +console.log(error.config); +}); ``` -Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error. +`validateStatus` कॉन्फ़िगरेशन विकल्प का उपयोग करके, आप HTTP कोड निर्धारित कर सकते हैं जो त्रुटि उत्पन्न करेगा। ```js axios.get('/user/12345', { - validateStatus: function (status) { - return status < 500; // Resolve only if the status code is less than 500 - } +validateStatus: function (status) { +return status < 500; // केवल तभी हल करें जब स्थिति कोड 500 से कम हो +} }) ``` -Using `toJSON` you get an object with more information about the HTTP error. +`toJSON` का उपयोग करके, आपको HTTP त्रुटि के बारे में अधिक जानकारी वाला एक ऑब्जेक्ट मिलता है। ```js axios.get('/user/12345') - .catch(function (error) { - console.log(error.toJSON()); - }); -``` +.catch(function (error) { +console.log(error.toJSON()); +}); +``` \ No newline at end of file diff --git a/posts/hi/instance.md b/posts/hi/instance.md index bd2a757b..ad8a9f48 100644 --- a/posts/hi/instance.md +++ b/posts/hi/instance.md @@ -1,28 +1,28 @@ --- -title: 'The Axios Instance' +title: 'Axios इंस्टेंस' prev_title: 'Axios API' prev_link: '/docs/api_intro' -next_title: 'Request Config' +next_title: 'रिक्वेस्ट कॉन्फ़िगरेशन' next_link: '/docs/req_config' --- -### Creating an instance +### इंस्टेंस बनाना -You can create a new instance of axios with a custom config. +आप कस्टम कॉन्फ़िगरेशन के साथ axios का एक नया इंस्टेंस बना सकते हैं। ##### axios.create([config]) ```js const instance = axios.create({ - baseURL: 'https://some-domain.com/api/', - timeout: 1000, - headers: {'X-Custom-Header': 'foobar'} +baseURL: 'https://some-domain.com/api/', +timeout: 1000, +headers: {'X-Custom-Header': 'foobar'} }); ``` -### Instance methods +### इंस्टेंस विधियाँ -The available instance methods are listed below. The specified config will be merged with the instance config. +उपलब्ध इंस्टेंस विधियाँ नीचे सूचीबद्ध हैं। निर्दिष्ट कॉन्फ़िगरेशन को इंस्टेंस कॉन्फ़िगरेशन के साथ मर्ज कर दिया जाएगा। ##### axios#request(config) ##### axios#get(url[, config]) @@ -34,29 +34,29 @@ The available instance methods are listed below. The specified config will be me ##### axios#patch(url[, data[, config]]) ##### axios#getUri([config]) -### Calling the instance with a config object +### कॉन्फ़िगरेशन ऑब्जेक्ट के साथ इंस्टेंस को कॉल करना -In addition to using convenience methods like `instance.get()` or `instance.post()`, you can also call an Axios instance directly with a config object. This is functionally equivalent to `axios(config)`, and is particularly useful when retrying a request using the original configuration. +`instance.get()` या `instance.post()` जैसी सुविधाजनक विधियों का उपयोग करने के अलावा, आप कॉन्फ़िगरेशन ऑब्जेक्ट के साथ सीधे Axios इंस्टेंस को भी कॉल कर सकते हैं। यह कार्यात्मक रूप से `axios(config)` के समतुल्य है, और मूल कॉन्फ़िगरेशन का उपयोग करके किसी अनुरोध का पुनः प्रयास करते समय विशेष रूप से उपयोगी है। ```js const instance = axios.create({ baseURL: '/api' }); -// Works just like axios(config) +// axios(config) की तरह ही कार्य करता है instance({ - url: '/users', - method: 'get' +url: '/users', +method: 'get' }); ``` -This approach enables clean retry logic when handling authentication errors: +यह दृष्टिकोण प्रमाणीकरण त्रुटियों को संभालते समय स्वच्छ पुनः प्रयास तर्क को सक्षम करता है: ```js instance.interceptors.response.use(undefined, async (error) => { - if (error.response?.status === 401) { - await refreshToken(); - return instance(error.config); // Retry original request - } +if (error.response?.status === 401) { +await refreshToken(); +return instance(error.config); // मूल अनुरोध का पुनः प्रयास करें +} - throw error; +throw error; }); -``` +``` \ No newline at end of file diff --git a/posts/hi/interceptors.md b/posts/hi/interceptors.md index 414790fa..f5b86d6c 100644 --- a/posts/hi/interceptors.md +++ b/posts/hi/interceptors.md @@ -1,55 +1,55 @@ --- -title: 'Interceptors' -prev_title: 'Config Defaults' +शीर्षक: 'इंटरसेप्टर' +prev_title: 'कॉन्फ़िगरेशन डिफ़ॉल्ट' prev_link: '/docs/config_defaults' -next_title: 'Handling Errors' +next_title: 'त्रुटियों का प्रबंधन' next_link: '/docs/handling_errors' --- -You can intercept requests or responses **before** they are handled by `then` or `catch`. +आप अनुरोधों या प्रतिक्रियाओं को `then` या `catch` द्वारा प्रबंधित किए जाने से **पहले** इंटरसेप्ट कर सकते हैं। -The `use` function adds a handler to the list of handlers to be run when the Promise is fulfilled or rejected. The handler is defined by the fulfilled and rejected functions. +`use` फ़ंक्शन, प्रॉमिस के पूरा होने या अस्वीकार होने पर चलाए जाने वाले हैंडलर्स की सूची में एक हैंडलर जोड़ता है। हैंडलर को पूरे और अस्वीकृत फ़ंक्शन द्वारा परिभाषित किया जाता है। -There is an optional `options` object that can be passed in as the third parameter. `synchronous` if the synchronous option is true. The handler is defined as asynchronous if the synchronous option is false. If the synchronous option is not provided, the handler is defined as asynchronous. `runWhen` will control when the provided interceptor will run. Provide a function that will return true or false on whether it should run, defaults to always true. +एक वैकल्पिक `options` ऑब्जेक्ट है जिसे तीसरे पैरामीटर के रूप में पास किया जा सकता है। यदि सिंक्रोनस विकल्प सत्य है, तो `synchronous`। यदि सिंक्रोनस विकल्प असत्य है, तो हैंडलर को एसिंक्रोनस के रूप में परिभाषित किया जाता है। यदि सिंक्रोनस विकल्प प्रदान नहीं किया गया है, तो हैंडलर को एसिंक्रोनस के रूप में परिभाषित किया जाता है। `runWhen` यह नियंत्रित करेगा कि प्रदान किया गया इंटरसेप्टर कब चलेगा। एक ऐसा फ़ंक्शन प्रदान करें जो यह तय करेगा कि उसे चलना चाहिए या नहीं, यह true या false लौटाएगा, डिफ़ॉल्ट रूप से हमेशा true होता है। ```js -// Add a request interceptor +// एक अनुरोध इंटरसेप्टर जोड़ें axios.interceptors.request.use(function (config) { - // Do something before request is sent - return config; - }, function (error) { - // Do something with request error - return Promise.reject(error); - }, - { synchronous: true, runWhen: () => /* This function returns true */} +// अनुरोध भेजे जाने से पहले कुछ करें +return config; +}, function (error) { +// अनुरोध त्रुटि के साथ कुछ करें +return Promise.reject(error); +}, +{ synchronous: true, runWhen: () => /* यह फ़ंक्शन true लौटाता है */} ); -// Add a response interceptor +/ एक प्रतिक्रिया इंटरसेप्टर जोड़ें axios.interceptors.response.use(function onFulfilled(response) { - // Any status code that lie within the range of 2xx cause this function to trigger - // Do something with response data - return response; - }, function onRejected(error) { - // Any status codes that falls outside the range of 2xx cause this function to trigger - // Do something with response error - return Promise.reject(error); - }); +/ 2xx की सीमा के भीतर आने वाला कोई भी स्थिति कोड इस फ़ंक्शन को ट्रिगर करता है +/ प्रतिक्रिया डेटा के साथ कुछ करें +return response; +}, function onRejected(error) { +/ 2xx की सीमा से बाहर आने वाला कोई भी स्थिति कोड इस फ़ंक्शन को ट्रिगर करता है +/ प्रतिक्रिया त्रुटि के साथ कुछ करें +return Promise.reject(error); +}); ``` -In normal circumstances the `onFulfilled` response interceptor is only called for responses in the 2xx range, and `onRejected` is called otherwise. -However, this behavior depends on [validateStatus](/docs/req_config). -For instance, if `validateStatus` is setup to always return `true`, then `onFulfilled` will be called for *all* responses. +सामान्य परिस्थितियों में, `onFulfilled` प्रतिक्रिया इंटरसेप्टर केवल 2xx रेंज में प्रतिक्रियाओं के लिए ही कॉल किया जाता है, अन्यथा `onRejected` को कॉल किया जाता है। +हालाँकि, यह व्यवहार [validateStatus](/docs/req_config) पर निर्भर करता है। +उदाहरण के लिए, यदि `validateStatus` को हमेशा `true` लौटाने के लिए सेट किया गया है, तो `onFulfilled` को *सभी* प्रतिक्रियाओं के लिए कॉल किया जाएगा। -If you need to remove an interceptor later you can. +यदि आपको बाद में किसी इंटरसेप्टर को हटाने की आवश्यकता हो, तो आप ऐसा कर सकते हैं। ```js const myInterceptor = axios.interceptors.request.use(function () {/*...*/}); axios.interceptors.request.eject(myInterceptor); ``` -You can add interceptors to a custom instance of axios. +आप axios के कस्टम इंस्टेंस में इंटरसेप्टर जोड़ सकते हैं। ```js const instance = axios.create(); -instance.interceptors.request.use(function () {/*...*/}); -``` +instance.interceptors.request.use(फ़ंक्शन () {/*...*/}); +``` \ No newline at end of file diff --git a/posts/hi/intro.md b/posts/hi/intro.md index 76b3b97f..35b84262 100644 --- a/posts/hi/intro.md +++ b/posts/hi/intro.md @@ -1,74 +1,74 @@ --- -title: 'Getting Started' -description: 'Promise based HTTP client for the browser and node.js' -next_title: 'Minimal Example' +title: 'आरंभ करें' +description: 'ब्राउज़र और node.js के लिए Promise-आधारित HTTP क्लाइंट' +next_title: 'न्यूनतम उदाहरण' next_link: '/docs/example' --- -# What is Axios? -Axios is a *[promise-based](https://javascript.info/promise-basics)* HTTP Client for [`node.js`](https://nodejs.org) and the browser. It is *[isomorphic](https://www.lullabot.com/articles/what-is-an-isomorphic-application)* (= it can run in the browser and node.js with the same codebase). On the server-side it uses the native node.js `http` module, while on the client (browser) it uses XMLHttpRequest. - -# Features - -- Make [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser -- Make [http](http://nodejs.org/api/http.html) requests from node.js -- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API -- Intercept request and response -- Transform request and response data -- Cancel requests -- Timeouts -- Query parameters serialization with support for nested entries -- Automatic request body serialization to: - - JSON (`application/json`) - - Multipart / FormData (`multipart/form-data`) - - URL encoded form (`application/x-www-form-urlencoded`) -- Posting HTML forms as JSON -- Automatic JSON data handling in response -- Progress capturing for browsers and node.js with extra info (speed rate, remaining time) -- Setting bandwidth limits for node.js -- Compatible with spec-compliant FormData and Blob (including `node.js`) -- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) - -# Installing - -Using npm: +# Axios क्या है? +Axios [`node.js`](https://nodejs.org) और ब्राउज़र के लिए एक *[promise-आधारित](https://javascript.info/promise-basics)* HTTP क्लाइंट है। यह *[isomorphic](https://www.lullabot.com/articles/what-is-an-isomorphic-application)* है (= यह ब्राउज़र और node.js में समान कोडबेस के साथ चल सकता है)। सर्वर-साइड पर यह मूल node.js `http` मॉड्यूल का उपयोग करता है, जबकि क्लाइंट (ब्राउज़र) पर यह XMLHttpRequest का उपयोग करता है। + +# विशेषताएँ + +- ब्राउज़र से [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) बनाएँ +- node.js से [http](http://nodejs.org/api/http.html) अनुरोध बनाएँ +- [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API का समर्थन करता है +- अनुरोध और प्रतिक्रिया को इंटरसेप्ट करें +- अनुरोध और प्रतिक्रिया डेटा को रूपांतरित करें +- अनुरोध रद्द करें +- टाइमआउट +- नेस्टेड प्रविष्टियों के समर्थन के साथ क्वेरी पैरामीटर क्रमांकन +- स्वचालित अनुरोध बॉडी क्रमांकन: +- JSON (`application/json`) +- मल्टीपार्ट / फ़ॉर्मडेटा (`multipart/form-data`) +- URL एन्कोडेड फ़ॉर्म (`application/x-www-form-urlencoded`) +- HTML फ़ॉर्म को JSON के रूप में पोस्ट करना +- स्वचालित प्रतिक्रिया में JSON डेटा प्रबंधन +- ब्राउज़र और node.js के लिए अतिरिक्त जानकारी (गति दर, शेष समय) के साथ प्रगति कैप्चरिंग +- node.js के लिए बैंडविड्थ सीमाएँ निर्धारित करना +- विनिर्देश-अनुपालक FormData और Blob (`node.js` सहित) के साथ संगत +- [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) से सुरक्षा के लिए क्लाइंट-साइड समर्थन + +# इंस्टॉल करना + +npm का उपयोग: ```bash $ npm install axios ``` -Using bower: +bower का उपयोग: ```bash $ bower install axios ``` -Using yarn: +yarn का उपयोग: ```bash $ yarn add axios ``` -Using pnpm: +pnpm का उपयोग: ```bash $ pnpm add axios ``` -Using jsDelivr CDN: +jsDelivr CDN का उपयोग: ```html ``` -Using unpkg CDN: +unpkg CDN का उपयोग: ```html ``` -Prebuilt CommonJS modules for direct importing with require (if your module bundler failed to resolve them automatically) +आवश्यकता के साथ सीधे आयात के लिए पूर्व-निर्मित CommonJS मॉड्यूल (यदि आपका मॉड्यूल बंडलर उन्हें स्वचालित रूप से हल करने में विफल रहा है) ```js -const axios = require('axios/dist/browser/axios.cjs'); // browser -const axios = require('axios/dist/node/axios.cjs'); // node +const axios = require('axios/dist/browser/axios.cjs'); // ब्राउज़र +const axios = require('axios/dist/node/axios.cjs'); // नोड ``` \ No newline at end of file diff --git a/posts/hi/multipart.md b/posts/hi/multipart.md index 08e3887d..5f4ceaee 100644 --- a/posts/hi/multipart.md +++ b/posts/hi/multipart.md @@ -1,64 +1,64 @@ --- -title: 'Multipart Bodies' -prev_title: 'URL-Encoding Bodies' -prev_link: '/docs/urlencoded' -next_title: 'Notes' -next_link: '/docs/notes' +शीर्षक: 'मल्टीपार्ट बॉडीज़' +पिछला_शीर्षक: 'यूआरएल-एन्कोडिंग बॉडीज़' +पिछला_लिंक: '/docs/urlencoded' +अगला_शीर्षक: 'नोट्स' +अगला_लिंक: '/docs/notes' --- -## Posting data as `multipart/form-data` +## डेटा को `मल्टीपार्ट/फ़ॉर्म-डेटा` के रूप में पोस्ट करना -### Using FormData API +### फ़ॉर्मडेटा एपीआई का उपयोग करना -#### Browser +#### ब्राउज़र -```js +```js const form = new FormData(); form.append('my_field', 'my value'); form.append('my_buffer', new Blob([1,2,3])); form.append('my_file', fileInput.files[0]); -axios.post('https://example.com', form) +axios.post('https://example.com', फ़ॉर्म) ``` -The same result can be achieved using the internal Axios serializer and corresponding shorthand method: +आंतरिक Axios सीरियलाइज़र और संबंधित शॉर्टहैंड विधि का उपयोग करके भी यही परिणाम प्राप्त किया जा सकता है: ```js axios.postForm('https://httpbin.org/post', { - my_field: 'my value', - my_buffer: new Blob([1,2,3]), - my_file: fileInput.files // FileList will be unwrapped as separate fields +my_field: 'my value', +my_buffer: new Blob([1,2,3]), +my_file: fileInput.files // FileList को अलग-अलग फ़ील्ड के रूप में अनरैप किया जाएगा }); ``` -HTML form can be passed directly as a request payload. +HTML फ़ॉर्म को सीधे अनुरोध पेलोड के रूप में पास किया जा सकता है। #### Node.js -```js -import axios from 'axios'; +```js +'axios' से axios आयात करें; const form = new FormData(); form.append('my_field', 'my value'); form.append('my_buffer', new Blob(['some content'])); -axios.post('https://example.com', form) +axios.post('https://example.com', फ़ॉर्म) ``` -Since node.js does not currently support creating a `Blob` from a file, you can use a third-party package for this purpose. +चूँकि node.js वर्तमान में किसी फ़ाइल से `Blob` बनाने का समर्थन नहीं करता है, आप इस उद्देश्य के लिए किसी तृतीय-पक्ष पैकेज का उपयोग कर सकते हैं। ```js -import {fileFromPath} from 'formdata-node/file-from-path' +'formdata-node/file-from-path' से {fileFromPath} आयात करें form.append('my_field', 'my value'); form.append('my_file', await fileFromPath('/foo/bar.jpg')); -axios.post('https://example.com', form) +axios.post('https://example.com', फ़ॉर्म) ``` -For Axios older than `v1.3.0` you must import `form-data` package. +`v1.3.0` से पुराने Axios के लिए, आपको `form-data` पैकेज आयात करना होगा। -```js +```js const FormData = require('form-data'); const form = new FormData(); @@ -69,65 +69,65 @@ form.append('my_file', fs.createReadStream('/foo/bar.jpg')); axios.post('https://example.com', form) ``` -### 🆕 Automatic serialization +### 🆕 स्वचालित क्रमांकन -Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData -object if the request Content-Type header is set to `multipart/form-data`. +`v0.27.0` से शुरू होकर, Axios, FormData +ऑब्जेक्ट में स्वचालित ऑब्जेक्ट क्रमांकन का समर्थन करता है, यदि अनुरोध Content-Type हेडर `multipart/form-data` पर सेट है। -The following request will submit the data in a FormData format (Browser & Node.js): +निम्नलिखित अनुरोध डेटा को FormData प्रारूप (ब्राउज़र और Node.js) में सबमिट करेगा: ```js -import axios from 'axios'; +'axios' से axios आयात करें; axios.post('https://httpbin.org/post', { - user: { - name: 'Dmitriy' - }, - file: fs.createReadStream('/foo/bar.jpg') +उपयोगकर्ता: { +नाम: 'दिमित्री' +}, +फ़ाइल: fs.createReadStream('/foo/bar.jpg') }, { - headers: { - 'Content-Type': 'multipart/form-data' - } +शीर्षलेख: { +'सामग्री-प्रकार': 'मल्टीपार्ट/फ़ॉर्म-डेटा' +} }).then(({data})=> console.log(data)); ``` -Axios FormData serializer supports some special endings to perform the following operations: +Axios FormData serializer निम्नलिखित ऑपरेशन करने के लिए कुछ विशेष अंत का समर्थन करता है: + +- `{}` - JSON.stringify के साथ मान को क्रमबद्ध करें +- `[]` - सरणी-जैसे ऑब्जेक्ट को समान कुंजी वाले अलग-अलग फ़ील्ड के रूप में अनरैप करें -- `{}` - serialize the value with JSON.stringify -- `[]` - unwrap the array-like object as separate fields with the same key +> नोट: +> अनरैप/विस्तार ऑपरेशन डिफ़ॉल्ट रूप से सरणी और FileList ऑब्जेक्ट पर उपयोग किया जाएगा -> NOTE: -> unwrap/expand operation will be used by default on arrays and FileList objects +FormData serializer दुर्लभ मामलों को संभालने के लिए `config.formSerializer: object` प्रॉपर्टी के माध्यम से अतिरिक्त विकल्पों का समर्थन करता है: -FormData serializer supports additional options via `config.formSerializer: object` property to handle rare cases: +- `visitor: Function` - उपयोगकर्ता-निर्धारित विज़िटर फ़ंक्शन जिसे कस्टम नियमों का पालन करके डेटा ऑब्जेक्ट को क्रमबद्ध करने के लिए पुनरावर्ती रूप से कॉल किया जाएगा +एक `FormData` ऑब्जेक्ट में। -- `visitor: Function` - user-defined visitor function that will be called recursively to serialize the data object -to a `FormData` object by following custom rules. +- `dots: boolean = false` - सरणी और ऑब्जेक्ट को क्रमबद्ध करने के लिए कोष्ठक के बजाय बिंदु संकेतन का उपयोग करें; -- `dots: boolean = false` - use dot notation instead of brackets to serialize arrays and objects; +- `metaTokens: boolean = true` - FormData कुंजी में विशेष अंत (जैसे `user{}: '{"name": "John"}'`) जोड़ें। +बैक-एंड बॉडी-पार्सर संभवतः इस मेटा-सूचना का उपयोग JSON के रूप में मान को स्वचालित रूप से पार्स करने के लिए कर सकता है। -- `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key. -The back-end body-parser could potentially use this meta-information to automatically parse the value as JSON. +- `indexes: null|false|true = false` - नियंत्रित करता है कि `flat` सरणी-जैसे ऑब्जेक्ट्स की अनरैप्ड कुंजियों में इंडेक्स कैसे जोड़े जाएँगे। -- `indexes: null|false|true = false` - controls how indexes will be added to unwrapped keys of `flat` array-like objects +- `null` - कोष्ठक न जोड़ें (`arr: 1`, `arr: 2`, `arr: 3`) +- `false`(डिफ़ॉल्ट) - रिक्त कोष्ठक जोड़ें (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`) +- `true` - इंडेक्स के साथ कोष्ठक जोड़ें (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`) - - `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`) - - `false`(default) - add empty brackets (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`) - - `true` - add brackets with indexes (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`) - -Let's say we have an object like this one: +मान लीजिए हमारे पास इस तरह का एक ऑब्जेक्ट है: ```js const obj = { - x: 1, - arr: [1, 2, 3], - arr2: [1, [2], 3], - users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], - 'obj2{}': [{x:1}] +x: 1, +arr: [1, 2, 3], +arr2: [1, [2], 3], +उपयोगकर्ता: [{नाम: 'पीटर', उपनाम: 'ग्रिफिन'}, {नाम: 'थॉमस', उपनाम: 'एंडरसन'}], +'obj2{}': [{x:1}] }; ``` -The following steps will be executed by the Axios serializer internally: +निम्नलिखित चरण Axios सीरियलाइज़र द्वारा आंतरिक रूप से निष्पादित किए जाएँगे: ```js const formData= new FormData(); @@ -138,33 +138,33 @@ formData.append('arr[]', '3'); formData.append('arr2[0]', '1'); formData.append('arr2[1][0]', '2'); formData.append('arr2[2]', '3'); -formData.append('users[0][name]', 'Peter'); -formData.append('users[0][surname]', 'Griffin'); -formData.append('users[1][name]', 'Thomas'); -formData.append('users[1][surname]', 'Anderson'); +formData.append('users[0][name]', 'पीटर'); +formData.append('users[0][surname]', 'ग्रिफिन'); +formData.append('users[1][name]', 'थॉमस'); +formData.append('users[1][surname]', 'एंडरसन'); formData.append('obj2{}', '[{"x":1}]'); ``` ```js -import axios from 'axios'; +'axios' से axios आयात करें; axios.post('https://httpbin.org/post', { - 'myObj{}': {x: 1, s: "foo"}, - 'files[]': document.querySelector('#fileInput').files +'myObj{}': {x: 1, s: "foo"}, +'files[]': document.querySelector('#fileInput').files }, { - headers: { - 'Content-Type': 'multipart/form-data' - } +headers: { +'Content-Type': 'multipart/form-data' +} }).then(({data})=> console.log(data)); ``` -Axios supports the following shortcut methods: `postForm`, `putForm`, `patchForm` -which are just the corresponding http methods with the content-type header preset to `multipart/form-data`. +Axios निम्नलिखित शॉर्टकट विधियों का समर्थन करता है: `postForm`, `putForm`, `patchForm` +जो कि संबंधित http विधियाँ हैं जिनका content-type हेडर `multipart/form-data` पर प्रीसेट है। -`FileList` object can be passed directly: +`FileList` ऑब्जेक्ट को सीधे पास किया जा सकता है: ```js await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files) ``` -All files will be sent with the same field names: `files[]`; +सभी फ़ाइलें समान फ़ील्ड नामों के साथ भेजी जाएँगी: `files[]`; \ No newline at end of file diff --git a/posts/hi/notes.md b/posts/hi/notes.md index 7f54e84d..69461939 100644 --- a/posts/hi/notes.md +++ b/posts/hi/notes.md @@ -1,38 +1,39 @@ --- -title: 'Notes' -description: 'A couple more notes to round it off' -prev_title: 'URL-Encoding Bodies' +title: 'नोट्स' +description: 'इसे पूर्ण करने के लिए कुछ और नोट्स' +prev_title: 'URL-एन्कोडिंग बॉडीज़' prev_link: '/docs/urlencoded' --- ## Semver -Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes. +जब तक axios `1.0` रिलीज़ तक नहीं पहुँच जाता, तब तक ब्रेकिंग परिवर्तन एक नए माइनर संस्करण के साथ जारी किए जाएँगे। उदाहरण के लिए, `0.5.1` और `0.5.4` में एक ही API होगा, लेकिन `0.6.0` में ब्रेकिंग परिवर्तन होंगे। ## Promises -axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises). -If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise). +axios [समर्थित](http://caniuse.com/promises) होने के लिए एक मूल ES6 प्रॉमिस कार्यान्वयन पर निर्भर करता है। -## TypeScript -axios includes [TypeScript](http://typescriptlang.org) definitions. -```typescript -import axios from 'axios'; +यदि आपका परिवेश ES6 प्रॉमिस का समर्थन नहीं करता है, तो आप [पॉलीफ़िल](https://github.com/jakearchibald/es6-promise) कर सकते हैं। + +## टाइपस्क्रिप्ट +axios में [टाइपस्क्रिप्ट](http://typescriptlang.org) परिभाषाएँ शामिल हैं। +```टाइपस्क्रिप्ट +'axios' से axios आयात करें; axios.get('/user?ID=12345'); ``` -## Resources +## संसाधन -* [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) -* [Upgrade Guide](https://github.com/axios/axios/blob/v1.x/UPGRADE_GUIDE.md) -* [Ecosystem](https://github.com/axios/axios/blob/v1.x/ECOSYSTEM.md) -* [Contributing Guide](https://github.com/axios/axios/blob/v1.x/CONTRIBUTING.md) -* [Code of Conduct](https://github.com/axios/axios/blob/v1.x/CODE_OF_CONDUCT.md) +* [चेंजलॉग](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) +* [अपग्रेड गाइड](https://github.com/axios/axios/blob/v1.x/UPGRADE_GUIDE.md) +* [इकोसिस्टम](https://github.com/axios/axios/blob/v1.x/ECOSYSTEM.md) +* [योगदान गाइड](https://github.com/axios/axios/blob/v1.x/CONTRIBUTING.md) +* [आचार संहिता](https://github.com/axios/axios/blob/v1.x/CODE_OF_CONDUCT.md) -## Credits +## श्रेय -axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular. +axios [$http [Angular](https://angularjs.org/) में प्रदान की गई सेवा](https://docs.angularjs.org/api/ng/service/$http)। अंततः, Axios, Angular के बाहर उपयोग के लिए एक स्टैंडअलोन `$http` जैसी सेवा प्रदान करने का एक प्रयास है। -## License +## लाइसेंस [MIT](https://github.com/axios/axios/blob/v1.x/LICENSE) \ No newline at end of file diff --git a/posts/hi/post_example.md b/posts/hi/post_example.md index 61731b4f..d5b3e9ab 100644 --- a/posts/hi/post_example.md +++ b/posts/hi/post_example.md @@ -1,88 +1,88 @@ --- -title: 'POST Requests' -description: 'How to perform POST requests with Axios' -prev_title: 'Minimal Example' -prev_link: '/docs/example' -next_title: 'Axios API' -next_link: '/docs/api_intro' +शीर्षक: 'POST अनुरोध' +विवरण: 'Axios के साथ POST अनुरोध कैसे करें' +पिछला_शीर्षक: 'न्यूनतम उदाहरण' +पिछला_लिंक: '/docs/example' +अगला_शीर्षक: 'Axios API' +अगला_लिंक: '/docs/api_intro' --- -## Performing a `POST` request +## `POST` अनुरोध निष्पादित करना ### JSON ```js axios.post('/user', { - firstName: 'Fred', - lastName: 'Flintstone' - }) - .then(function (response) { - console.log(response); - }) - .catch(function (error) { - console.log(error); - }); +पहला नाम: 'Fred', +अंतिम नाम: 'Flintstone' +}) +.then(function (response) { +console.log(response); +}) +.catch(function (error) { +console.log(error); +}); ``` -Performing multiple concurrent requests +एक साथ कई अनुरोध निष्पादित करना ```js -function getUserAccount() { - return axios.get('/user/12345'); +फ़ंक्शन getUserAccount() { +return axios.get('/user/12345'); } -function getUserPermissions() { - return axios.get('/user/12345/permissions'); +फ़ंक्शन getUserPermissions() { +return axios.get('/user/12345/permissions'); } const [acct, perm] = await Promise.all([getUserAccount(), getUserPermissions()]); -// OR +/ या Promise.all([getUserAccount(), getUserPermissions()]) - .then(function ([acct, perm]) { - // ... - }); +.then(फ़ंक्शन ([acct, perm]) { +/ ... +}); ``` -Post an HTML form as JSON +एक HTML फ़ॉर्म को JSON के रूप में पोस्ट करें ```js const {data} = await axios.post('/user', document.querySelector('#my-form'), { - headers: { - 'Content-Type': 'application/json' - } +हेडर: { +'Content-Type': 'application/json' +} }) ``` -### Forms +### फ़ॉर्म -- Multipart (`multipart/form-data`) +- मल्टीपार्ट (`multipart/form-data`) ```js const {data} = await axios.post('https://httpbin.org/post', { - firstName: 'Fred', - lastName: 'Flintstone', - orders: [1, 2, 3], - photo: document.querySelector('#fileInput').files - }, { - headers: { - 'Content-Type': 'multipart/form-data' - } - } +firstName: 'Fred', +lastName: 'Flintstone', +orders: [1, 2, 3], +photo: document.querySelector('#fileInput').files +}, { +हेडर: { +'Content-Type': 'multipart/form-data' +} +} ) ``` -- URL encoded form (`application/x-www-form-urlencoded`) +- URL एनकोडेड फ़ॉर्म (`application/x-www-form-urlencoded`) ```js const {data} = await axios.post('https://httpbin.org/post', { - firstName: 'Fred', - lastName: 'Flintstone', - orders: [1, 2, 3] - }, { - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } +firstName: 'Fred', +lastName: 'Flintstone', +orders: [1, 2, 3] +}, { +headers: { +'Content-Type': 'application/x-www-form-urlencoded' +} }) -``` +``` \ No newline at end of file diff --git a/posts/hi/req_config.md b/posts/hi/req_config.md index db6702e3..9650fe57 100644 --- a/posts/hi/req_config.md +++ b/posts/hi/req_config.md @@ -1,257 +1,120 @@ --- -title: 'Request Config' -prev_title: 'The Axios Instance' +title: 'अनुरोध कॉन्फ़िगरेशन' +prev_title: 'Axios इंस्टेंस' prev_link: '/docs/instance' -next_title: 'Response Schema' +next_title: 'प्रतिक्रिया स्कीमा' next_link: '/docs/res_schema' --- - -These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified. +अनुरोध करने के लिए ये उपलब्ध कॉन्फ़िगरेशन विकल्प हैं। केवल `url` आवश्यक है। यदि `method` निर्दिष्ट नहीं है, तो अनुरोध डिफ़ॉल्ट रूप से `GET` पर सेट हो जाएँगे। ```js { - // `url` is the server URL that will be used for the request - url: '/user', - - // `method` is the request method to be used when making the request - method: 'get', // default - - // `baseURL` will be prepended to `url` unless `url` is absolute. - // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs - // to methods of that instance. - baseURL: 'https://some-domain.com/api', - - // `allowAbsoluteUrls` determines whether or not absolute URLs will override a configured `baseUrl`. - // When set to true (default), absolute values for `url` will override `baseUrl`. - // When set to false, absolute values for `url` will always be prepended by `baseUrl`. - allowAbsoluteUrls: true, - - // `transformRequest` allows changes to the request data before it is sent to the server - // This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE' - // The last function in the array must return a string or an instance of Buffer, ArrayBuffer, - // FormData or Stream - // You may modify the headers object. - transformRequest: [function (data, headers) { - // Do whatever you want to transform the data - - return data; - }], - - // `transformResponse` allows changes to the response data to be made before - // it is passed to then/catch - transformResponse: [function (data) { - // Do whatever you want to transform the data - - return data; - }], - - // `headers` are custom headers to be sent - headers: {'X-Requested-With': 'XMLHttpRequest'}, - - // `params` are the URL parameters to be sent with the request - // Must be a plain object or a URLSearchParams object - // NOTE: params that are null or undefined are not rendered in the URL. - params: { - ID: 12345 - }, - - // `paramsSerializer` is an optional config in charge of serializing `params` - paramsSerializer: { - encode?: (param: string): string => { /* Do custom ops here and return transformed string */ }, // custom encoder function; sends Key/Values in an iterative fashion - serialize?: (params: Record, options?: ParamsSerializerOptions ), // mimic pre 1.x behavior and send entire params object to a custom serializer func. Allows consumer to control how params are serialized. - indexes: false // array indexes format (null - no brackets, false (default) - empty brackets, true - brackets with indexes) - }, - - // `data` is the data to be sent as the request body - // Only applicable for request methods 'PUT', 'POST', 'DELETE', and 'PATCH' - // When no `transformRequest` is set, must be of one of the following types: - // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams - // - Browser only: FormData, File, Blob - // - Node only: Stream, Buffer - data: { - firstName: 'Fred' - }, - - // syntax alternative to send data into the body - // method post - // only the value is sent, not the key - data: 'Country=Brasil&City=Belo Horizonte', - - // `timeout` specifies the number of milliseconds before the request times out. - // If the request takes longer than `timeout`, the request will be aborted. - timeout: 1000, // default is `0` (no timeout) - - // `withCredentials` indicates whether or not cross-site Access-Control requests - // should be made using credentials - withCredentials: false, // default - - // `adapter` allows custom handling of requests which makes testing easier. - // Return a promise and supply a valid response (see lib/adapters/README.md). - adapter: function (config) { - /* ... */ - }, - - // `auth` indicates that HTTP Basic auth should be used, and supplies credentials. - // This will set an `Authorization` header, overwriting any existing - // `Authorization` custom headers you have set using `headers`. - // Please note that only HTTP Basic auth is configurable through this parameter. - // For Bearer tokens and such, use `Authorization` custom headers instead. - auth: { - username: 'janedoe', - password: 's00pers3cret' - }, - - // `responseType` indicates the type of data that the server will respond with - // options are: 'arraybuffer', 'document', 'json', 'text', 'stream' - // browser only: 'blob' - responseType: 'json', // default - - // `responseEncoding` indicates encoding to use for decoding responses (Node.js only) - // Note: Ignored for `responseType` of 'stream' or client-side requests - responseEncoding: 'utf8', // default - - // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token - xsrfCookieName: 'XSRF-TOKEN', // default - - // `xsrfHeaderName` is the name of the http header that carries the xsrf token value - xsrfHeaderName: 'X-XSRF-TOKEN', // default - - // `onUploadProgress` allows handling of progress events for uploads - // browser only - onUploadProgress: function (progressEvent) { - // Do whatever you want with the native progress event - }, - - // `onDownloadProgress` allows handling of progress events for downloads - // browser only - onDownloadProgress: function (progressEvent) { - // Do whatever you want with the native progress event - }, - - // `maxContentLength` defines the max size of the http response content in bytes allowed in node.js - maxContentLength: 2000, - - // `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed - maxBodyLength: 2000, - - // `validateStatus` defines whether to resolve or reject the promise for a given - // HTTP response status code. If `validateStatus` returns `true` (or is set to `null` - // or `undefined`), the promise will be resolved; otherwise, the promise will be - // rejected. - validateStatus: function (status) { - return status >= 200 && status < 300; // default - }, - - // `maxRedirects` defines the maximum number of redirects to follow in node.js. - // If set to 0, no redirects will be followed. - maxRedirects: 21, // default - - // `beforeRedirect` defines a function that will be called before redirect. - // Use this to adjust the request options upon redirecting, - // to inspect the latest response headers, - // or to cancel the request by throwing an error - // If maxRedirects is set to 0, `beforeRedirect` is not used. - beforeRedirect: (options, { headers }) => { - if (options.hostname === "example.com") { - options.auth = "user:password"; - } - }, - - // `socketPath` defines a UNIX Socket to be used in node.js. - // e.g. '/var/run/docker.sock' to send requests to the docker daemon. - // Only either `socketPath` or `proxy` can be specified. - // If both are specified, `socketPath` is used. - socketPath: null, // default - - // `transport` determines the transport method that will be used to make the request. If defined, it will be used. Otherwise, if `maxRedirects` is 0, the default `http` or `https` library will be used, depending on the protocol specified in `protocol`. Otherwise, the `httpFollow` or `httpsFollow` library will be used, again depending on the protocol, which can handle redirects. - transport: undefined, // default - - // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http - // and https requests, respectively, in node.js. This allows options to be added like - // `keepAlive` that are not enabled by default before Node.js v19.0.0. After Node.js - // v19.0.0, you no longer need to customize the agent to enable `keepAlive` because - // `http.globalAgent` has `keepAlive` enabled by default. - httpAgent: new http.Agent({ keepAlive: true }), - httpsAgent: new https.Agent({ keepAlive: true }), - - // `proxy` defines the hostname, port, and protocol of the proxy server. - // You can also define your proxy using the conventional `http_proxy` and - // `https_proxy` environment variables. If you are using environment variables - // for your proxy configuration, you can also define a `no_proxy` environment - // variable as a comma-separated list of domains that should not be proxied. - // Use `false` to disable proxies, ignoring environment variables. - // Disable if supplying a custom httpAgent/httpsAgent to manage proxying requests. - // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and - // supplies credentials. - // This will set an `Proxy-Authorization` header, overwriting any existing - // `Proxy-Authorization` custom headers you have set using `headers`. - // If the proxy server uses HTTPS, then you must set the protocol to `https`. - proxy: { - protocol: 'https', - host: '127.0.0.1', - port: 9000, - auth: { - username: 'mikeymike', - password: 'rapunz3l' - } - }, - - // `signal` and instance of AbortController can be used to cancel the request - signal: new AbortController().signal, - - // (Deprecated) `cancelToken` specifies a cancel token that can also be used to cancel the request - // (see Cancellation section below for details) - cancelToken: new CancelToken(function (cancel) { - }), - - // an alternative way to cancel Axios requests using AbortController - signal: new AbortController().signal, - - // `decompress` indicates whether or not the response body should be decompressed - // automatically. If set to `true` will also remove the 'content-encoding' header - // from the responses objects of all decompressed responses - // - Node only (XHR cannot turn off decompression) - decompress: true // default - - // `insecureHTTPParser` boolean. - // Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers. - // This may allow interoperability with non-conformant HTTP implementations. - // Using the insecure parser should be avoided. - // see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback - // see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-none - insecureHTTPParser: undefined // default - - // transitional options for backward compatibility that may be removed in the newer versions - transitional: { - // silent JSON parsing mode - // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour) - // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json') - silentJSONParsing: true, // default value for the current Axios version - - // try to parse the response string as JSON even if `responseType` is not 'json' - forcedJSONParsing: true, - - // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts - clarifyTimeoutError: false, - }, - - env: { - // The FormData class to be used to automatically serialize the payload into a FormData object - FormData: window?.FormData || global?.FormData - }, - - formSerializer: { - visitor: (value, key, path, helpers) => {}; // custom visitor function to serialize form values - dots: boolean; // use dots instead of brackets format - metaTokens: boolean; // keep special endings like {} in parameter key - indexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes - }, - - // http adapter only (node.js) - maxRate: [ - 100 * 1024, // 100KB/s upload limit, - 100 * 1024 // 100KB/s download limit - ] -} -``` +// `url` वह सर्वर URL है जिसका उपयोग अनुरोध के लिए किया जाएगा +url: '/user', + +// `method` वह अनुरोध विधि है जिसका उपयोग अनुरोध करते समय किया जाएगा +method: 'get', // डिफ़ॉल्ट + +// `url` के आगे `baseURL` जोड़ा जाएगा, जब तक कि `url` निरपेक्ष न हो। +// axios के किसी इंस्टेंस के लिए `baseURL` सेट करना सुविधाजनक हो सकता है ताकि उस इंस्टेंस के मेथड्स को सापेक्ष URL +/ पास किए जा सकें। +baseURL: 'https://some-domain.com/api' + +// `allowAbsoluteUrls` यह निर्धारित करता है कि निरपेक्ष URL कॉन्फ़िगर किए गए `baseUrl` को ओवरराइड करेंगे या नहीं। +// जब true (डिफ़ॉल्ट) पर सेट किया जाता है, तो `url` के निरपेक्ष मान `baseUrl` को ओवरराइड कर देंगे। +// जब false पर सेट किया जाता है, तो `url` के निरपेक्ष मान हमेशा `baseUrl` से पहले जोड़े जाएँगे। +allowAbsoluteUrls: true + +// `transformRequest` सर्वर पर भेजे जाने से पहले अनुरोध डेटा में बदलाव की अनुमति देता है। +// यह केवल अनुरोध विधियों 'PUT', 'POST', 'PATCH' और 'DELETE' के लिए लागू है। +// सरणी में अंतिम फ़ंक्शन को एक स्ट्रिंग या Buffer, ArrayBuffer का एक उदाहरण लौटाना होगा। +// FormData या Stream +// आप हेडर ऑब्जेक्ट को संशोधित कर सकते हैं। +transformRequest: [function (data, headers) { +// डेटा को रूपांतरित करने के लिए आप जो चाहें करें। + +return data; +}], + +// `transformResponse` प्रतिक्रिया डेटा में बदलाव करने की अनुमति देता है +// इसे then/catch में पास किया जाता है +transformResponse: [function (data) { +// डेटा को रूपांतरित करने के लिए आप जो चाहें करें + +return data; +}], + +// `headers` भेजे जाने वाले कस्टम हेडर हैं +headers: {'X-Requested-With': 'XMLHttpRequest'}, + +// `params` अनुरोध के साथ भेजे जाने वाले URL पैरामीटर हैं +// एक साधारण ऑब्जेक्ट या URLSearchParams ऑब्जेक्ट होना चाहिए +// नोट: जो पैरामीटर शून्य या अपरिभाषित हैं, उन्हें URL में रेंडर नहीं किया जाता है। +पैरामीटर: { +आईडी: 12345 +}, + +// `paramsSerializer` एक वैकल्पिक कॉन्फ़िगरेशन है जो `params` को क्रमबद्ध करने के लिए ज़िम्मेदार है। +पैरामीटर: { +encode?: (param: string): string => { /* यहाँ कस्टम ऑप्स करें और रूपांतरित स्ट्रिंग लौटाएँ */ }, // कस्टम एनकोडर फ़ंक्शन; कुंजी/मानों को पुनरावृत्तीय रूप में भेजता है। +serialize?: (params: Record, options?: ParamsSerializerOptions ), // 1.x से पहले के व्यवहार की नकल करता है और संपूर्ण पैरामीटर ऑब्जेक्ट को एक कस्टम सीरियलाइज़र फ़ंक्शन पर भेजता है। उपभोक्ता को यह नियंत्रित करने की अनुमति देता है कि पैरामीटर कैसे क्रमबद्ध किए जाएँ। +अनुक्रमणिकाएँ: असत्य // सरणी अनुक्रमणिका प्रारूप (शून्य - कोई कोष्ठक नहीं, असत्य (डिफ़ॉल्ट) - रिक्त कोष्ठक, सत्य - अनुक्रमणिकाओं वाले कोष्ठक) +}, + +// `data` वह डेटा है जिसे अनुरोध बॉडी के रूप में भेजा जाना है +// केवल अनुरोध विधियों 'PUT', 'POST', 'DELETE', और 'PATCH' के लिए लागू +// जब कोई `transformRequest` सेट नहीं है, तो निम्न में से किसी एक प्रकार का होना चाहिए: +// - स्ट्रिंग, सादा ऑब्जेक्ट, ArrayBuffer, ArrayBufferView, URLSearchParams +// - केवल ब्राउज़र: FormData, फ़ाइल, Blob +// - केवल नोड: स्ट्रीम, बफ़र +डेटा: { +firstName: 'Fred' +}, + +// बॉडी में डेटा भेजने के लिए सिंटैक्स विकल्प +// विधि post +// केवल मान भेजा जाता है, कुंजी नहीं +डेटा: 'Country=Brasil&City=Belo Horizonte', + +// `timeout`, मिलीसेकंड की संख्या निर्दिष्ट करता है अनुरोध का समय समाप्त हो गया है। +// यदि अनुरोध `timeout` से अधिक समय लेता है, तो अनुरोध निरस्त कर दिया जाएगा। +timeout: 1000, // डिफ़ॉल्ट `0` है (कोई समय समाप्ति नहीं) + +// `withCredentials` इंगित करता है कि क्रॉस-साइट एक्सेस-कंट्रोल अनुरोध +// क्रेडेंशियल्स का उपयोग करके किए जाने चाहिए या नहीं +withCredentials: गलत, // डिफ़ॉल्ट + +// `adapter` अनुरोधों को कस्टम हैंडलिंग की अनुमति देता है जिससे परीक्षण आसान हो जाता है। +// एक वादा लौटाएँ और एक मान्य प्रतिक्रिया प्रदान करें (lib/adapters/README.md देखें)। +adapter: फ़ंक्शन (config) { +/* ... */ +}, + +// `auth` इंगित करता है कि HTTP Basic auth का उपयोग किया जाना चाहिए, और क्रेडेंशियल प्रदान करता है। +// यह एक `Authorization` हेडर सेट करेगा, जो आपके द्वारा `headers` का उपयोग करके सेट किए गए किसी भी मौजूदा +// `Authorization` कस्टम हेडर को अधिलेखित कर देगा। +// कृपया ध्यान दें कि इस पैरामीटर के माध्यम से केवल HTTP Basic auth को कॉन्फ़िगर किया जा सकता है। + +// Bearer टोकन आदि के लिए, `Authorization` कस्टम हेडर का उपयोग करें। +auth: { +उपयोगकर्ता नाम: 'janedoe', +पासवर्ड: 's00pers3cret' +}, + +// `responseType` उस डेटा के प्रकार को इंगित करता है जिसके साथ सर्वर प्रतिक्रिया देगा +// विकल्प हैं: 'arraybuffer', 'document', 'json', 'text', 'stream' +// केवल ब्राउज़र: 'blob' +responseType: 'json', // डिफ़ॉल्ट + +// `responseEncoding` प्रतिक्रियाओं को डिकोड करने के लिए उपयोग की जाने वाली एन्कोडिंग को इंगित करता है (केवल Node.js) +// नोट: 'stream' या क्लाइंट-साइड अनुरोधों के `responseType` के लिए अनदेखा किया गया +responseEncoding: 'utf8', // डिफ़ॉल्ट + +// `xsrfCookieName`, xsrf टोकन के मान के रूप में उपयोग की जाने वाली कुकी का नाम है +xsrfCookieName: 'XSRF-TOKEN', // डिफ़ॉल्ट + +// `xsrfHeaderName`, http का नाम है xsrf टोकन मान वाला हेडर +xsrfHeaderName: 'X-XSRF-TOKEN', // डिफ़ॉल्ट + +// `onUploadProgress` अपलोड के लिए प्रगति ईवेंट को संभालने की अनुमति देता है \ No newline at end of file diff --git a/posts/hi/res_schema.md b/posts/hi/res_schema.md index d33eb3ef..9a25a125 100644 --- a/posts/hi/res_schema.md +++ b/posts/hi/res_schema.md @@ -1,52 +1,52 @@ --- -title: 'Response Schema' -prev_title: 'Request Config' +शीर्षक: 'प्रतिक्रिया स्कीमा' +prev_title: 'अनुरोध कॉन्फ़िगरेशन' prev_link: '/docs/req_config' -next_title: 'Config Defaults' +next_title: 'कॉन्फ़िगरेशन डिफ़ॉल्ट' next_link: '/docs/config_defaults' --- -The response for a request contains the following information. +अनुरोध के प्रतिसाद में निम्नलिखित जानकारी होती है। ```js { - // `data` is the response that was provided by the server - data: {}, +// `data` सर्वर द्वारा प्रदान की गई प्रतिक्रिया है +data: {}, - // `status` is the HTTP status code from the server response - status: 200, +// `status` सर्वर प्रतिक्रिया से HTTP स्थिति कोड है +status: 200, - // `statusText` is the HTTP status message from the server response - // As of HTTP/2 status text is blank or unsupported. - // (HTTP/2 RFC: https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2.4) - statusText: 'OK', +// `statusText` सर्वर प्रतिक्रिया से HTTP स्थिति संदेश है +// HTTP/2 से स्थिति पाठ रिक्त या असमर्थित है। +// (HTTP/2 RFC: https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2.4) +statusText: 'OK', - // `headers` the HTTP headers that the server responded with - // All header names are lower cased and can be accessed using the bracket notation. - // Example: `response.headers['content-type']` - headers: {}, +// `headers` वे HTTP हेडर जिनके साथ सर्वर ने प्रतिक्रिया दी +// सभी हेडर नाम लोअर केस में हैं और ब्रैकेट नोटेशन का उपयोग करके एक्सेस किए जा सकते हैं। +// उदाहरण: `response.headers['content-type']` +शीर्षक: {}, - // `config` is the config that was provided to `axios` for the request - config: {}, +// `config` वह कॉन्फ़िगरेशन है जो अनुरोध के लिए `axios` को प्रदान किया गया था +कॉन्फ़िगरेशन: {}, - // `request` is the request that generated this response - // It is the last ClientRequest instance in node.js (in redirects) - // and an XMLHttpRequest instance in the browser - request: {} +// `request` वह अनुरोध है जिसने यह प्रतिक्रिया उत्पन्न की +// यह node.js (रीडायरेक्ट में) में अंतिम ClientRequest इंस्टेंस है +// और ब्राउज़र में एक XMLHttpRequest इंस्टेंस है +अनुरोध: {} } ``` -When using `then`, you will receive the response as follows: +`then` का उपयोग करते समय, आपको निम्न प्रकार से प्रतिक्रिया प्राप्त होगी: ```js axios.get('/user/12345') - .then(function (response) { - console.log(response.data); - console.log(response.status); - console.log(response.statusText); - console.log(response.headers); - console.log(response.config); - }); +.then(function (response) { +console.log(response.data); +console.log(response.status); +console.log(response.statusText); +console.log(response.headers); +console.log(response.config); +}); ``` -When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as second parameter of `then`, the response will be available through the `error` object as explained in the [Handling Errors](/docs/handling_errors) section. +`catch` का उपयोग करते समय, या `then` के दूसरे पैरामीटर के रूप में [अस्वीकृति कॉलबैक](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) पास करते समय, प्रतिक्रिया `error` ऑब्जेक्ट के माध्यम से उपलब्ध होगी, जैसा कि [त्रुटियों को संभालना](/docs/handling_errors) अनुभाग में बताया गया है। \ No newline at end of file diff --git a/posts/hi/sponsor.md b/posts/hi/sponsor.md index 07f07ef1..589524c0 100644 --- a/posts/hi/sponsor.md +++ b/posts/hi/sponsor.md @@ -1,90 +1,89 @@ --- -title: 'Sponsoring Axios' +शीर्षक: 'एक्सियोस को प्रायोजित करना' --- -Thank you for considering supporting our project. Your donation will be used to maintain and develop Axios. +हमारे प्रोजेक्ट का समर्थन करने के लिए धन्यवाद। आपके दान का उपयोग एक्सियोस के रखरखाव और विकास के लिए किया जाएगा। -As a benefit to our major sponsors, we provide the opportunity to add your logo and brief -information to our website and/or [Readme.md](https://github.com/axios/axios) depending on the tier of support you choose. -This process is fully automated if you donate through [OpenCollective.com](https://opencollective.com/axios/contribute), -so your logo will be added within 24 hours. +हमारे प्रमुख प्रायोजकों के लाभ के लिए, हम आपको अपना लोगो और संक्षिप्त +जानकारी हमारी वेबसाइट और/या [Readme.md](https://github.com/axios/axios) पर जोड़ने का अवसर प्रदान करते हैं, जो आपके द्वारा चुने गए समर्थन स्तर पर निर्भर करता है। +यदि आप [OpenCollective.com](https://opencollective.com/axios/contribute) के माध्यम से दान करते हैं, तो यह प्रक्रिया पूरी तरह से स्वचालित है, +इसलिए आपका लोगो 24 घंटों के भीतर जोड़ दिया जाएगा। -Your logo can be placed: -- in the carousel on the main page -- in carousels on each page of the documentation -- at the top of [Readme.md](https://github.com/axios/axios) in our repo +आपका लोगो निम्न स्थानों पर रखा जा सकता है: +- मुख्य पृष्ठ पर कैरोसेल में +- दस्तावेज़ के प्रत्येक पृष्ठ पर कैरोसेल में +- हमारी रेपो में [Readme.md](https://github.com/axios/axios) के शीर्ष पर -Place in the carousel depends on: -- newness of the sponsor (new sponsors temporarily receive higher places) -- selected support tier -- total amount of money donated -- consistency of donations +कैरोसेल में स्थान इस पर निर्भर करता है: +- प्रायोजक की नवीनता (नए प्रायोजकों को अस्थायी रूप से उच्च स्थान प्राप्त होते हैं) +- चयनित समर्थन स्तर +- दान की कुल राशि +- दान की एकरूपता -If you donate through [GitHub](https://github.com/sponsors/axios), you will need to contact us later if you want your logo to be promoted according -to our support tiers. +यदि आप [GitHub](https://github.com/sponsors/axios) के माध्यम से दान करते हैं, तो आपको बाद में हमसे संपर्क करना होगा यदि आप चाहते हैं कि आपका लोगो +हमारे समर्थन स्तरों के अनुसार प्रचारित हो। -### Tiers +## स्तर -See tiers list on [Open Collective](https://opencollective.com/axios/contribute) +[Open Collective](https://opencollective.com/axios/contribute) पर स्तरों की सूची देखें -| | Bronze | Silver | Gold | Platinum | -|---------------------------------------------|:----------:|:-----------:|:-----------:|:----------------:| -| Main page | small logo | medium logo | large logo | extra large logo | -| Docs pages | | | medium logo | large logo | -| [Readme.md](https://github.com/axios/axios) | | | small logo | medium logo | -| Data merging from sponsor's GitHub repo | | + | + | + | -| Links block in tooltip* | | | + | + | -| Embedded Youtube video in tooltip* | | | + | + | -| Max description length in Readme.md (chars) | | | 100 | 150 | +| | कांस्य | रजत | स्वर्ण | प्लेटिनम | +|---------------------------------------------|:-----------:|:------:|:------:|:----------------:| +| मुख्य पृष्ठ | छोटा लोगो | मध्यम लोगो | बड़ा लोगो | अतिरिक्त बड़ा लोगो | +| दस्तावेज़ पृष्ठ | | | मध्यम लोगो | बड़ा लोगो | +| [Readme.md](https://github.com/axios/axios) | | | छोटा लोगो | मध्यम लोगो | +| प्रायोजक के GitHub रेपो से डेटा मर्ज किया जा रहा है | | + | + | + | +| टूलटिप* में लिंक ब्लॉक | | | + | + | +| टूलटिप* में एम्बेड किया गया YouTube वीडियो | | | + | + | +| Readme.md में अधिकतम विवरण लंबाई (अक्षर) | | | 100 | 150 | -> Note: -> The extra links block and video can only be set via `sponsors.json` +> नोट: +> अतिरिक्त लिंक ब्लॉक और वीडियो केवल `sponsors.json` के माध्यम से सेट किए जा सकते हैं। -### Backer tier +### समर्थक स्तर -You can create a custom tier, in which case you will get the benefits of the highest existing tier whose price -is covered by your donation. The extra donation amount above the existing tier will be taken into account -when sorting sponsors in a carousel. +आप एक कस्टम स्तर बना सकते हैं, इस स्थिति में आपको मौजूदा उच्चतम स्तर का लाभ मिलेगा जिसकी कीमत +आपके दान से पूरी हो जाएगी। मौजूदा स्तर से ऊपर की अतिरिक्त दान राशि को कैरोसेल में प्रायोजकों को छांटते समय ध्यान में रखा जाएगा। -### Sponsor logo +### प्रायोजक लोगो -Your logo will be downloaded to our server, optimized, trimmed empty borders and resized with preservation of proportions. -If the width of the logo is significantly greater than its height, then the text caption will be hidden, -and the logo will take up all the available space. The maximum logo height is the same for all tiers. +आपका लोगो हमारे सर्वर पर डाउनलोड किया जाएगा, अनुकूलित किया जाएगा, खाली बॉर्डर काटे जाएँगे और अनुपात को बनाए रखते हुए उसका आकार बदला जाएगा। +यदि लोगो की चौड़ाई उसकी ऊँचाई से काफ़ी ज़्यादा है, तो टेक्स्ट कैप्शन छिपा दिया जाएगा, +और लोगो उपलब्ध सभी जगह घेर लेगा। सभी स्तरों के लिए लोगो की अधिकतम ऊँचाई समान है। -### Description +### विवरण -If the description is not provided, we will try to parse it from the sponsor's site meta tags. +यदि विवरण प्रदान नहीं किया गया है, तो हम इसे प्रायोजक की साइट मेटा टैग से पार्स करने का प्रयास करेंगे। ### GitHub -If you have set up your GitHub profile in your Open Collective profile, -you can create a special repository called `axios-sponsor` with `sponsor.json` in its root to manage your sponsor profile data. +अगर आपने अपनी ओपन कलेक्टिव प्रोफ़ाइल में अपनी GitHub प्रोफ़ाइल सेट अप की है, तो +आप अपने प्रायोजक प्रोफ़ाइल डेटा को प्रबंधित करने के लिए `axios-sponsor` नामक एक विशेष रिपॉजिटरी बना सकते हैं, जिसके रूट में `sponsor.json` होगा। -The data from this file will be merged with your Open Collective profile which allows you to provide some extra info for advertising. +इस फ़ाइल का डेटा आपकी ओपन कलेक्टिव प्रोफ़ाइल में मर्ज कर दिया जाएगा, जिससे आप विज्ञापन के लिए कुछ अतिरिक्त जानकारी प्रदान कर सकेंगे। -`sponsor.json` has the following structure (each field is optional): +`sponsor.json` की संरचना इस प्रकार है (प्रत्येक फ़ील्ड वैकल्पिक है): ```json - { - "displayName": "Umbrella Corporation", - "targetLink": "https://umbrellacorp.com/", - "alt": "Umbrella Corporation", - "image": "https://fake.com/logo.png", - "image_dark": "https://fake.com/logo_dark.png", - "description": "The Umbrella Corporation is a pharmaceutical company", - "website": "https://google.com/", - "github": "https://github.com/fakeGitHib", - "icon": "https://fake.com/icon.png", - "video": "https://www.youtube.com/embed/isosE4Bowh0", - "twitter": "https://x.com/profile", - "showCaption": true, - "crown": false, - "hide": false, - "links": { - "link1": "https://google.com/", - "link2": "https://google.com/" - } - } +{ +"displayName": "अम्ब्रेला कॉर्पोरेशन", +"targetLink": "https://umbrellacorp.com/", +"alt": "अम्ब्रेला कॉर्पोरेशन", +"image": "https://fake.com/logo.png", +"image_dark": "https://fake.com/logo_dark.png", +"description": "अम्ब्रेला कॉर्पोरेशन एक दवा कंपनी है", +"website": "https://google.com/", +"github": "https://github.com/fakeGitHib", +"icon": "https://fake.com/icon.png", +"video": "https://www.youtube.com/embed/isosE4Bowh0", +"twitter": "https://x.com/profile", +"showCaption": true, +"क्राउन": गलत, +"छिपाएँ": गलत, +"लिंक": { +"लिंक1": "https://google.com/", +"लिंक2": "https://google.com/" +} +} ``` -Every 24 hour our backend will pull this data when update sponsors list on the website. +वेबसाइट पर प्रायोजकों की सूची अपडेट करते समय हमारा बैकएंड हर 24 घंटे में यह डेटा खींचेगा। \ No newline at end of file diff --git a/posts/hi/urlencoded.md b/posts/hi/urlencoded.md index 1c2b8c66..30efbc82 100644 --- a/posts/hi/urlencoded.md +++ b/posts/hi/urlencoded.md @@ -1,16 +1,16 @@ --- -title: 'URL-Encoding Bodies' -prev_title: 'Cancellation' +title: 'URL-एन्कोडिंग बॉडीज़' +prev_title: 'रद्दीकरण' prev_link: '/docs/cancellation' -next_title: 'Multipart Bodies' +next_title: 'मल्टीपार्ट बॉडीज़' next_link: '/docs/multipart' --- -By default, axios serializes JavaScript objects to `JSON`. To send data in the `application/x-www-form-urlencoded` format instead, you can use one of the following approaches. +डिफ़ॉल्ट रूप से, axios JavaScript ऑब्जेक्ट्स को `JSON` में क्रमबद्ध करता है। इसके बजाय, `application/x-www-form-urlencoded` फ़ॉर्मैट में डेटा भेजने के लिए, आप निम्न में से किसी एक तरीके का उपयोग कर सकते हैं। -### Browser +### ब्राउज़र -In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows: +ब्राउज़र में, आप [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API का उपयोग इस प्रकार कर सकते हैं: ```js const params = new URLSearchParams(); @@ -19,41 +19,41 @@ params.append('param2', 'value2'); axios.post('/foo', params); ``` -> Note that `URLSearchParams` is not supported by all browsers (see [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment). +> ध्यान दें कि `URLSearchParams` सभी ब्राउज़रों द्वारा समर्थित नहीं है (देखें [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), लेकिन एक [polyfill](https://github.com/WebReflection/url-search-params) उपलब्ध है (ध्यान रखें कि वैश्विक परिवेश को पॉलीफ़िल करें)। -Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library: +वैकल्पिक रूप से, आप [`qs`](https://github.com/ljharb/qs) लाइब्रेरी का उपयोग करके डेटा को एनकोड कर सकते हैं: ```js const qs = require('qs'); axios.post('/foo', qs.stringify({ 'bar': 123 })); ``` -Or in another way (ES6), +या दूसरे तरीके से (ES6), ```js -import qs from 'qs'; +'qs' से qs आयात करें; const data = { 'bar': 123 }; const options = { - method: 'POST', - headers: { 'content-type': 'application/x-www-form-urlencoded' }, - data: qs.stringify(data), - url, +method: 'POST', +headers: { 'content-type': 'application/x-www-form-urlencoded' }, +data: qs.stringify(data), +url, }; axios(options); ``` ### Node.js -#### Query string +#### क्वेरी स्ट्रिंग -In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: +node.js में, आप [`querystring`](https://nodejs.org/api/querystring.html) मॉड्यूल का उपयोग इस प्रकार कर सकते हैं: ```js const querystring = require('querystring'); axios.post('http://something.com/', querystring.stringify({ foo: 'bar' })); ``` -or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows: +या ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) ['url module'](https://nodejs.org/api/url.html) से इस प्रकार: ```js const url = require('url'); @@ -61,59 +61,59 @@ const params = new url.URLSearchParams({ foo: 'bar' }); axios.post('http://something.com/', params.toString()); ``` -You can also use the [`qs`](https://github.com/ljharb/qs) library. +आप [`qs`](https://github.com/ljharb/qs) लाइब्रेरी का भी उपयोग कर सकते हैं। -> Note: The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665). +> नोट: यदि आपको नेस्टेड ऑब्जेक्ट्स को स्ट्रिंग करना है, तो `qs` लाइब्रेरी बेहतर है, क्योंकि `querystring` विधि में इस उपयोग के मामले में ज्ञात समस्याएँ हैं (https://github.com/nodejs/node-v0.x-archive/issues/1665)। -### 🆕 Automatic serialization +### 🆕 स्वचालित क्रमांकन -Axios will automatically serialize the data object to urlencoded format if the `content-type` header is set to `application/x-www-form-urlencoded`. +यदि `content-type` हेडर `application/x-www-form-urlencoded` पर सेट है, तो Axios डेटा ऑब्जेक्ट को urlencoded फ़ॉर्मेट में स्वचालित रूप से क्रमांकित कर देगा। -This works both in the browser and in `node.js`: +यह ब्राउज़र और `node.js` दोनों में काम करता है: ```js const data = { - x: 1, - arr: [1, 2, 3], - arr2: [1, [2], 3], - users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], +x: 1, +arr: [1, 2, 3], +arr2: [1, [2], 3], +users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], }; await axios.post('https://postman-echo.com/post', data, - {headers: {'content-type': 'application/x-www-form-urlencoded'}} +{headers: {'content-type': 'application/x-www-form-urlencoded'}} ); ``` -The server will handle it as +सर्वर इसे इस प्रकार संभालेगा ```js - { - x: '1', - 'arr[]': [ '1', '2', '3' ], - 'arr2[0]': '1', - 'arr2[1][0]': '2', - 'arr2[2]': '3', - 'arr3[]': [ '1', '2', '3' ], - 'users[0][name]': 'Peter', - 'users[0][surname]': 'griffin', - 'users[1][name]': 'Thomas', - 'users[1][surname]': 'Anderson' - } +{ +x: '1', +'arr[]': [ '1', '2', '3' ], +'arr2[0]': '1', +'arr2[1][0]': '2', +'arr2[2]': '3', +'arr3[]': [ '1', '2', '3' ], +'users[0][name]': 'पीटर', +'users[0][surname]': 'ग्रिफिन', +'users[1][name]': 'थॉमस', +'users[1][surname]': 'एंडरसन' +} ```` -If your server framework's request body parser (like `body-parser` of `express.js`) supports nested objects decoding, -you will automatically receive the same server object that you submitted. +यदि आपके सर्वर फ्रेमवर्क का अनुरोध बॉडी पार्सर (जैसे `express.js` का `body-parser`) नेस्टेड ऑब्जेक्ट डिकोडिंग का समर्थन करता है, +तो आपको स्वचालित रूप से प्राप्त होगा वही सर्वर ऑब्जेक्ट जो आपने सबमिट किया था। -Echo server example (`express.js`) : +इको सर्वर उदाहरण (`express.js`): ```js - var app = express(); - - app.use(bodyParser.urlencoded({ extended: true })); // support url-encoded bodies - - app.post('/', function (req, res, next) { - res.send(JSON.stringify(req.body)); - }); - - server = app.listen(3000); -``` +var app = express(); + +app.use(bodyParser.urlencoded({ extended: true })); // url-एन्कोडेड बॉडीज़ का समर्थन करता है + +app.post('/', function (req, res, next) { +res.send(JSON.stringify(req.body)); +}); + +server = app.listen(3000); +``` \ No newline at end of file From c874c40b742473c9c8a71ec1777d62a9dda45bbe Mon Sep 17 00:00:00 2001 From: Arun Kaushik <46048646+incrediblenura@users.noreply.github.com> Date: Mon, 10 Nov 2025 00:05:43 +0530 Subject: [PATCH 7/9] Update api_intro.md --- posts/hi/api_intro.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/posts/hi/api_intro.md b/posts/hi/api_intro.md index 3614e34a..04f1b1f0 100644 --- a/posts/hi/api_intro.md +++ b/posts/hi/api_intro.md @@ -1,10 +1,10 @@ --- -शीर्षक: 'एक्सियोस एपीआई' -विवरण: 'एक्सियोस एपीआई संदर्भ' -पिछला_शीर्षक: 'पोस्ट अनुरोध' -पिछला_लिंक: '/docs/post_example' -अगला_शीर्षक: 'एक्सियोस इंस्टेंस' -अगला_लिंक: '/docs/instance' +title: 'Axios API' +description: 'Axios API संदर्भ' +prev_title: 'पोस्ट अनुरोध' +prev_link: '/docs/post_example' +next_title: 'एक्सियोस इंस्टेंस' +next_link: '/docs/instance' --- संबंधित कॉन्फ़िगरेशन को `axios` में पास करके अनुरोध किए जा सकते हैं। @@ -56,4 +56,4 @@ axios('/user/12345'); ##### axios.patch(url[, data[, config]]) ##### axios.postForm(url[, data[, config]]) ##### axios.putForm(url[, data[, config]]) -##### axios.patchForm(url[, data[, config]]) उपनाम विधियों `url`, `method`, और `data` का उपयोग करते समय गुणों को कॉन्फ़िगरेशन में निर्दिष्ट करने की आवश्यकता नहीं होती है। \ No newline at end of file +##### axios.patchForm(url[, data[, config]]) उपनाम विधियों `url`, `method`, और `data` का उपयोग करते समय गुणों को कॉन्फ़िगरेशन में निर्दिष्ट करने की आवश्यकता नहीं होती है। From fc73dfabee7c8dffdc1224e6186b3fb14ea87979 Mon Sep 17 00:00:00 2001 From: Arun Kaushik <46048646+incrediblenura@users.noreply.github.com> Date: Mon, 10 Nov 2025 00:06:17 +0530 Subject: [PATCH 8/9] Update cancellation.md --- posts/hi/cancellation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posts/hi/cancellation.md b/posts/hi/cancellation.md index 9cae6055..3d523ed3 100644 --- a/posts/hi/cancellation.md +++ b/posts/hi/cancellation.md @@ -1,5 +1,5 @@ --- -शीर्षक: 'रद्दीकरण' +title: 'रद्दीकरण' prev_title: 'त्रुटियों का प्रबंधन' prev_link: '/docs/handling_errors' next_title: 'URL-एन्कोडिंग निकाय' @@ -141,4 +141,4 @@ cancelToken: source.token source.cancel('उपयोगकर्ता द्वारा कार्रवाई रद्द कर दी गई।'); // या controller.abort(); // संदेश पैरामीटर समर्थित नहीं है -``` \ No newline at end of file +``` From 4312299f5aa16749df7060f1c564200edcc661c5 Mon Sep 17 00:00:00 2001 From: Arun Kaushik <46048646+incrediblenura@users.noreply.github.com> Date: Mon, 10 Nov 2025 00:14:50 +0530 Subject: [PATCH 9/9] Add files via upload --- posts/hi/api_intro.md | 6 +++--- posts/hi/cancellation.md | 4 ++-- posts/hi/config_defaults.md | 2 +- posts/hi/example.md | 4 ++-- posts/hi/handling_errors.md | 10 +++++----- posts/hi/interceptors.md | 2 +- posts/hi/multipart.md | 10 +++++----- posts/hi/post_example.md | 12 ++++++------ posts/hi/res_schema.md | 2 +- posts/hi/sponsor.md | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/posts/hi/api_intro.md b/posts/hi/api_intro.md index 04f1b1f0..39df4dcc 100644 --- a/posts/hi/api_intro.md +++ b/posts/hi/api_intro.md @@ -1,6 +1,6 @@ --- -title: 'Axios API' -description: 'Axios API संदर्भ' +title: 'एक्सियोस एपीआई' +description: 'एक्सियोस एपीआई संदर्भ' prev_title: 'पोस्ट अनुरोध' prev_link: '/docs/post_example' next_title: 'एक्सियोस इंस्टेंस' @@ -56,4 +56,4 @@ axios('/user/12345'); ##### axios.patch(url[, data[, config]]) ##### axios.postForm(url[, data[, config]]) ##### axios.putForm(url[, data[, config]]) -##### axios.patchForm(url[, data[, config]]) उपनाम विधियों `url`, `method`, और `data` का उपयोग करते समय गुणों को कॉन्फ़िगरेशन में निर्दिष्ट करने की आवश्यकता नहीं होती है। +##### axios.patchForm(url[, data[, config]]) उपनाम विधियों `url`, `method`, और `data` का उपयोग करते समय गुणों को कॉन्फ़िगरेशन में निर्दिष्ट करने की आवश्यकता नहीं होती है। \ No newline at end of file diff --git a/posts/hi/cancellation.md b/posts/hi/cancellation.md index 3d523ed3..12b1de8d 100644 --- a/posts/hi/cancellation.md +++ b/posts/hi/cancellation.md @@ -1,5 +1,5 @@ --- -title: 'रद्दीकरण' +title: 'कैन्सीलेशन' prev_title: 'त्रुटियों का प्रबंधन' prev_link: '/docs/handling_errors' next_title: 'URL-एन्कोडिंग निकाय' @@ -141,4 +141,4 @@ cancelToken: source.token source.cancel('उपयोगकर्ता द्वारा कार्रवाई रद्द कर दी गई।'); // या controller.abort(); // संदेश पैरामीटर समर्थित नहीं है -``` +``` \ No newline at end of file diff --git a/posts/hi/config_defaults.md b/posts/hi/config_defaults.md index edea1348..1de11379 100644 --- a/posts/hi/config_defaults.md +++ b/posts/hi/config_defaults.md @@ -1,5 +1,5 @@ --- -शीर्षक: 'कॉन्फ़िगरेशन डिफ़ॉल्ट' +title: 'कॉन्फ़िगरेशन डिफ़ॉल्ट' prev_title: 'प्रतिक्रिया स्कीमा' prev_link: '/docs/res_schema' next_title: 'इंटरसेप्टर' diff --git a/posts/hi/example.md b/posts/hi/example.md index cfde31d3..9438381f 100644 --- a/posts/hi/example.md +++ b/posts/hi/example.md @@ -1,6 +1,6 @@ --- -शीर्षक: 'न्यूनतम उदाहरण' -विवरण: 'axios के उपयोग का एक छोटा सा उदाहरण' +title: 'न्यूनतम उदाहरण' +description: 'axios के उपयोग का एक छोटा सा उदाहरण' prev_title: 'परिचय' prev_link: '/docs/intro' next_title: 'POST अनुरोध' diff --git a/posts/hi/handling_errors.md b/posts/hi/handling_errors.md index de3582d6..687ff45e 100644 --- a/posts/hi/handling_errors.md +++ b/posts/hi/handling_errors.md @@ -1,9 +1,9 @@ --- -शीर्षक: 'त्रुटियों का प्रबंधन' -पिछला_शीर्षक: 'इंटरसेप्टर' -पिछला_लिंक: '/docs/interceptors' -अगला_शीर्षक: 'रद्दीकरण' -अगला_लिंक: '/docs/रद्दीकरण' +title: 'त्रुटियों का प्रबंधन' +prev_title: 'इंटरसेप्टर' +prev_link: '/docs/interceptors' +next_title: 'रद्दीकरण' +next_link: '/docs/रद्दीकरण' --- एक्सियोस त्रुटियों की सामान्य संरचना इस प्रकार है: diff --git a/posts/hi/interceptors.md b/posts/hi/interceptors.md index f5b86d6c..b5cafa65 100644 --- a/posts/hi/interceptors.md +++ b/posts/hi/interceptors.md @@ -1,5 +1,5 @@ --- -शीर्षक: 'इंटरसेप्टर' +title: 'इंटरसेप्टर' prev_title: 'कॉन्फ़िगरेशन डिफ़ॉल्ट' prev_link: '/docs/config_defaults' next_title: 'त्रुटियों का प्रबंधन' diff --git a/posts/hi/multipart.md b/posts/hi/multipart.md index 5f4ceaee..7918b49c 100644 --- a/posts/hi/multipart.md +++ b/posts/hi/multipart.md @@ -1,9 +1,9 @@ --- -शीर्षक: 'मल्टीपार्ट बॉडीज़' -पिछला_शीर्षक: 'यूआरएल-एन्कोडिंग बॉडीज़' -पिछला_लिंक: '/docs/urlencoded' -अगला_शीर्षक: 'नोट्स' -अगला_लिंक: '/docs/notes' +title: 'मल्टीपार्ट बॉडीज़' +prev_title: 'यूआरएल-एन्कोडिंग बॉडीज़' +prev_link: '/docs/urlencoded' +next_title: 'नोट्स' +next_link: '/docs/notes' --- ## डेटा को `मल्टीपार्ट/फ़ॉर्म-डेटा` के रूप में पोस्ट करना diff --git a/posts/hi/post_example.md b/posts/hi/post_example.md index d5b3e9ab..c1cd5fb3 100644 --- a/posts/hi/post_example.md +++ b/posts/hi/post_example.md @@ -1,10 +1,10 @@ --- -शीर्षक: 'POST अनुरोध' -विवरण: 'Axios के साथ POST अनुरोध कैसे करें' -पिछला_शीर्षक: 'न्यूनतम उदाहरण' -पिछला_लिंक: '/docs/example' -अगला_शीर्षक: 'Axios API' -अगला_लिंक: '/docs/api_intro' +title: 'POST अनुरोध' +description: 'Axios के साथ POST अनुरोध कैसे करें' +prev_title: 'न्यूनतम उदाहरण' +prev_link: '/docs/example' +next_link: '/docs/api_intro' +next_title: 'Axios API' --- ## `POST` अनुरोध निष्पादित करना diff --git a/posts/hi/res_schema.md b/posts/hi/res_schema.md index 9a25a125..9e9b8647 100644 --- a/posts/hi/res_schema.md +++ b/posts/hi/res_schema.md @@ -1,5 +1,5 @@ --- -शीर्षक: 'प्रतिक्रिया स्कीमा' +title: 'प्रतिक्रिया स्कीमा' prev_title: 'अनुरोध कॉन्फ़िगरेशन' prev_link: '/docs/req_config' next_title: 'कॉन्फ़िगरेशन डिफ़ॉल्ट' diff --git a/posts/hi/sponsor.md b/posts/hi/sponsor.md index 589524c0..3d381735 100644 --- a/posts/hi/sponsor.md +++ b/posts/hi/sponsor.md @@ -1,5 +1,5 @@ --- -शीर्षक: 'एक्सियोस को प्रायोजित करना' +title: 'एक्सियोस को प्रायोजित करना' --- हमारे प्रोजेक्ट का समर्थन करने के लिए धन्यवाद। आपके दान का उपयोग एक्सियोस के रखरखाव और विकास के लिए किया जाएगा।