Using the CloudFlare API with NodeJS and superagent


#1

Hello,

I am trying to understand how the request for the CloudFlare NPM package should be configured so that I can add a record to the DNS Zone: https://github.com/cloudflare/node-cloudflare

Maybe I am a bit sleepy now but here is what I am trying after settign up the correct email and Global API key:

Here is what I am trying:

cf.zones.add(zoneID, ‘{“type”: “A”, “name”: “example.com”, “content”: “127.0.0.1”, “ttl”: 120, “proxied”: false }’).then(function (resp) {
return resp.result.status;
});

And the result:

(node:3208) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Cloudflare: Unknown arguments (ZONE_ID_HIDDEN_FROM_COMMUNITY,{“type”: “A”, “name”: “example.com”,
“content”: “127.0.0.1”, “ttl”: 120, “proxied”: false }). Did you mean to pass an options object? (on API request to POST zones/)

Note: I am testing the API from a local machine.
Note2: The requests for the .cf.zones.read work without any issues, just can’t seem to understand how this one works.

Thank you.