mirror of
https://github.com/axios/axios.git
synced 2026-04-11 14:21:59 +08:00
* Fixes #10610 Deprecation Warning : url.parse() is deprecated in Node.js v22 (via follow-redirects) * Fixes #10610 Deprecation Warning : fixed again * Apply suggestion from @cubic-dev-ai[bot] Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: tona jose <tona00jose@gmail.com> Co-authored-by: Jay <jasonsaayman@gmail.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
24 lines
539 B
JavaScript
24 lines
539 B
JavaScript
export default function (req, res) {
|
|
let parsedUrl;
|
|
try {
|
|
parsedUrl = new URL(req.url, 'http://localhost');
|
|
} catch {
|
|
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
|
res.end('Invalid URL');
|
|
return;
|
|
}
|
|
const delay = parsedUrl.searchParams.get('delay') || 3000;
|
|
|
|
setTimeout(() => {
|
|
res.writeHead(200, {
|
|
'Content-Type': 'text/json',
|
|
});
|
|
res.write(
|
|
JSON.stringify({
|
|
message: 'Response completed successfully after ' + delay + 'ms',
|
|
})
|
|
);
|
|
res.end();
|
|
}, delay);
|
|
}
|