justadude09786
justadude09786
CDCloudflare Developers
Created by justadude09786 on 2/12/2024 in #general-help
DNS Create Request works in Postman but not NodeJS
I always get a
{
success: false,
errors: [ { code: 10000, message: 'Authentication error' } ]
}
{
success: false,
errors: [ { code: 10000, message: 'Authentication error' } ]
}
when making requests via my Node app but the same works in Postman which makes no sense cause I have copied the code from Postman into my Node app. I have tried fetch and axios but both return the same error. Here’s the code
return axios
.request({
method: 'post',
url: 'https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records',
headers: {
Authorization: `Bearer ${apiKey}`
},
data: {
"name": "${name}",
"type": "TXT",
"content": "dnslink=/ipfs/${cid}"
}
return axios
.request({
method: 'post',
url: 'https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records',
headers: {
Authorization: `Bearer ${apiKey}`
},
data: {
"name": "${name}",
"type": "TXT",
"content": "dnslink=/ipfs/${cid}"
}
Any help is appreciated!
1 replies