fix: don't stringify record twice

This commit is contained in:
Maciej Krüger 2019-06-23 20:34:20 +02:00
parent c4ac31eccd
commit a6ef089076
No known key found for this signature in database
GPG Key ID: 0D948CE19CF49C5F
1 changed files with 3 additions and 2 deletions

View File

@ -70,13 +70,14 @@ module.exports.create = function (config) {
dnsPrefix dnsPrefix
} }
} = data } = data
console.log(data)
const zone = await getZone(domain) const zone = await getZone(domain)
if (zone.permissions.indexOf('#zone:edit') === -1) { if (zone.permissions.indexOf('#zone:edit') === -1) {
throw new Error('Can not edit zone ' + JSON.stringify(domain) + ' from this account') 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) { if (resp.statusCode !== 200) {
formatError('Could not add record', resp) formatError('Could not add record', resp)
} }
@ -137,7 +138,7 @@ module.exports.create = function (config) {
let record = result.filter(record => (record.type === 'TXT'))[0] let record = result.filter(record => (record.type === 'TXT'))[0]
if (record) { if (record) {
return {dnsAuthorization: JSON.parse(record.content)} return {dnsAuthorization: record.content}
} else { } else {
return null // TODO: not found. should this throw?! return null // TODO: not found. should this throw?!
} }