From 38d6b5b97e58cdef52385380a91f9bbeada7ed7e Mon Sep 17 00:00:00 2001 From: KostLinux Date: Tue, 26 Mar 2024 15:35:24 +0200 Subject: [PATCH] Fix bug with JSON Doctype #120 --- api/dnssec.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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