diff --git a/api/dnssec.js b/api/dnssec.js index 1ce4bfbe..afaa955f 100644 --- a/api/dnssec.js +++ b/api/dnssec.js @@ -25,7 +25,11 @@ const handler = async (domain) => { }); res.on('end', () => { - resolve(JSON.parse(data)); + try { + resolve(JSON.parse(data)); + } catch (error) { + reject(new Error('Invalid JSON response')); + } }); res.on('error', error => { @@ -50,5 +54,4 @@ const handler = async (domain) => { }; module.exports = middleware(handler); -module.exports.handler = middleware(handler); - +module.exports.handler = middleware(handler); \ No newline at end of file