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:
@@ -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);
|
||||
};
|
||||
Reference in New Issue
Block a user