/
githubmirror
/
axios
Обзор
Документация
Войти
/
githubmirror
/
axios
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.x
examples/abort-controller/server.js
23 строки
539 B
Kai Lee
Fixes #10610 Deprecation Warning : url.parse() is deprecated in Node.… (#10625)
02 апр 2026, 10:02
Не верифицирован
02 апр 2026, 10:02
947f709
Код
Авторство
О чём код?
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); }