TypeError: x.toJSON is not a function
Environment details
- OS: windows10 and also with ubuntu 20.0.4
- Node.js version: tried with 14.5.0 and with 18.10.0, 18.7.0
- npm version: 16.4.5, and corresponding versions that match the node version
@google-cloud/dnsversion: 3.0.1, and 3.0.0
Steps to reproduce
- Try adding a record to a zone
- see error UnhandledPromiseRejectionWarning: TypeError: x.toJSON is not a function, originates from node_modules@google-cloud\dns\build\src\zone.js:333:55
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!
Hi @SethBlakley, can you post your code to reproduce and any errors in the Github issue itself? Thank you.
Hi @SethBlakley, can you post your code to reproduce and any errors in the Github issue itself? Thank you.
I added a txt of my code in the ticket. and the single step to reproduce witch is "Try adding a record to a zone". What else am I missing or is it not in the correct format? I'll give any information needed and thank you for your time in advance.
@SethBlakley thank you for the additional information, I've added this to our bug backlog.
Sorry @SethBlakley, I didn't see that file originally!
I think you need to create a record before adding it, like so:
const aRecord = {
zone_: "INSERTZONENAMEHERE",
type: "A",
metadata: {
name: 'example.com.',
data: '1.2.3.4',
ttl: 300,
type: "A",
},
};
async function main() {
// First create the record
let record = await ZONE.record('a', aRecord);
// Then add it
await ZONE.addRecords(record)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
}
main();
Let me know if this works for you!
Will close this for now, but please feel free to reopen if it's still an issue.