Skip to content

Commit ce3c142

Browse files
muraliQlogicJustinBeckwith
authored andcommitted
docs(samples): Update samples to use async/await (#159)
1 parent fa12e66 commit ce3c142

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

packages/google-cloud-dns/samples/quickstart.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,19 @@
1919
// Imports the Google Cloud client library
2020
const {DNS} = require('@google-cloud/dns');
2121

22-
// Your Google Cloud Platform project ID
23-
const projectId = 'YOUR_PROJECT_ID';
22+
async function quickStart() {
23+
// Your Google Cloud Platform project ID
24+
const projectId = 'YOUR_PROJECT_ID';
2425

25-
// Creates a client
26-
const dns = new DNS({
27-
projectId: projectId,
28-
});
29-
30-
// Lists all zones in the current project
31-
dns
32-
.getZones()
33-
.then(results => {
34-
const zones = results[0];
35-
36-
console.log('Zones:');
37-
zones.forEach(zone => console.log(zone.name));
38-
})
39-
.catch(err => {
40-
console.error('ERROR:', err);
26+
// Creates a client
27+
const dns = new DNS({
28+
projectId: projectId,
4129
});
30+
31+
// Lists all zones in the current project
32+
const [zones] = await dns.getZones();
33+
console.log('Zones:');
34+
zones.forEach(zone => console.log(zone.name));
35+
}
36+
quickStart().catch(console.error);
4237
// [END dns_quickstart]

0 commit comments

Comments
 (0)