mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
docs: refresh CDN URLs and example JSON headers (#7236)
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -189,13 +189,13 @@ const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundl
|
|||||||
Using jsDelivr CDN (ES5 UMD browser module):
|
Using jsDelivr CDN (ES5 UMD browser module):
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/axios@1.6.7/dist/axios.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/axios@1.13.2/dist/axios.min.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
Using unpkg CDN:
|
Using unpkg CDN:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://unpkg.com/axios@1.6.7/dist/axios.min.js"></script>
|
<script src="https://unpkg.com/axios@1.13.2/dist/axios.min.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const people = [
|
|||||||
|
|
||||||
export default function (req, res) {
|
export default function (req, res) {
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
'Content-Type': 'text/json'
|
'Content-Type': 'application/json'
|
||||||
});
|
});
|
||||||
res.write(JSON.stringify(people));
|
res.write(JSON.stringify(people));
|
||||||
res.end();
|
res.end();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default function (req, res) {
|
|||||||
req.on('end', function () {
|
req.on('end', function () {
|
||||||
console.log('POST data received');
|
console.log('POST data received');
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
'Content-Type': 'text/json'
|
'Content-Type': 'application/json'
|
||||||
});
|
});
|
||||||
res.write(JSON.stringify(data));
|
res.write(JSON.stringify(data));
|
||||||
res.end();
|
res.end();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default function (req, res) {
|
|||||||
req.on('end', function () {
|
req.on('end', function () {
|
||||||
console.log('POST received');
|
console.log('POST received');
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
'Content-Type': 'text/json'
|
'Content-Type': 'application/json'
|
||||||
});
|
});
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const composeSignals = (signals, timeout) => {
|
|||||||
|
|
||||||
let timer = timeout && setTimeout(() => {
|
let timer = timeout && setTimeout(() => {
|
||||||
timer = null;
|
timer = null;
|
||||||
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT))
|
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT))
|
||||||
}, timeout)
|
}, timeout)
|
||||||
|
|
||||||
const unsubscribe = () => {
|
const unsubscribe = () => {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ describe('helpers::composeSignals', () => {
|
|||||||
signal.addEventListener('abort', resolve);
|
signal.addEventListener('abort', resolve);
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.match(String(signal.reason), /timeout 100 of ms exceeded/);
|
assert.match(String(signal.reason), /timeout of 100ms exceeded/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return undefined if signals and timeout are not provided', async () => {
|
it('should return undefined if signals and timeout are not provided', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user