From a6ef089076a4ca0a7d1c65117c531599d47c98ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Sun, 23 Jun 2019 20:34:20 +0200 Subject: [PATCH] fix: don't stringify record twice --- lib/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 5f5f885..0e9959a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -70,13 +70,14 @@ module.exports.create = function (config) { dnsPrefix } } = data + console.log(data) const zone = await getZone(domain) if (zone.permissions.indexOf('#zone:edit') === -1) { throw new Error('Can not edit zone ' + JSON.stringify(domain) + ' from this account') } - const resp = await api('POST', `/zones/${zone.id}/dns_records`, {type: 'TXT', name: dnsPrefix, content: JSON.stringify(txtRecord), ttl: 300}) + const resp = await api('POST', `/zones/${zone.id}/dns_records`, {type: 'TXT', name: dnsPrefix, content: txtRecord, ttl: 300}) if (resp.statusCode !== 200) { formatError('Could not add record', resp) } @@ -137,7 +138,7 @@ module.exports.create = function (config) { let record = result.filter(record => (record.type === 'TXT'))[0] if (record) { - return {dnsAuthorization: JSON.parse(record.content)} + return {dnsAuthorization: record.content} } else { return null // TODO: not found. should this throw?! }