mirror of
https://github.com/axios/axios.git
synced 2026-04-11 14:21:59 +08:00
17 lines
385 B
JavaScript
17 lines
385 B
JavaScript
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);
|
|
};
|