2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-05 16:42:32 +03:00

docs: add abort controller example (#7287)

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Akash Dhar Dubey
2025-12-30 16:39:44 +05:30
committed by GitHub
parent bf3f63237c
commit 38be3b2e18
2 changed files with 148 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
import url from 'url';
export default function (req, res) {
const parsedUrl = url.parse(req.url, true);
const delay = parsedUrl.query.delay || 3000;
setTimeout(() => {
res.writeHead(200, {
'Content-Type': 'text/json'
});
res.write(JSON.stringify({
message: 'Response completed successfully after ' + delay + 'ms'
}));
res.end();
}, delay);
};