Skip to content

Commit

Permalink
docs(samples): updated samples code to use async await (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenqlogic authored and JustinBeckwith committed Nov 23, 2018
1 parent 64bd843 commit e433583
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions packages/google-cloud-resourcemanager/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,26 @@

'use strict';

// [START resource_quickstart]
// Imports the Google Cloud client library
const {Resource} = require('@google-cloud/resource');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';

// Creates a client
const resourceClient = new Resource({
projectId: projectId,
});

// Lists current projects
resourceClient
.getProjects()
.then(results => {
const projects = results[0];

console.log('Projects:');
projects.forEach(project => console.log(project.id));
})
.catch(err => {
console.error('ERROR:', err);
async function main() {
// [START resource_quickstart]
// Imports the Google Cloud client library
const {Resource} = require('@google-cloud/resource');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';

// Creates a client
const resourceClient = new Resource({
projectId: projectId,
});
// [END resource_quickstart]

// Lists current projects
const [projects] = await resourceClient.getProjects();

console.log('Projects:');
projects.forEach(project => console.log(project.id));

// [END resource_quickstart]
}

main().catch(console.error);

0 comments on commit e433583

Please sign in to comment.