Skip to content

Commit

Permalink
docs(samples): updated samples code to use async/await and tests to u…
Browse files Browse the repository at this point in the history
…se mocha (#241)
  • Loading branch information
vijay-qlogic authored and JustinBeckwith committed Nov 18, 2018
1 parent bc44fbe commit d55eec2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
6 changes: 2 additions & 4 deletions packages/google-cloud-vision/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"node": ">=8"
},
"scripts": {
"test": "ava -T 1m --verbose system-test/*.test.js"
"test": "mocha system-test/*.test.js --timeout 600000"
},
"dependencies": {
"@google-cloud/automl": "^0.1.1",
Expand All @@ -22,9 +22,7 @@
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"@google-cloud/storage": "^2.0.0",
"ava": "^0.25.0",
"proxyquire": "^2.0.1",
"sinon": "^7.0.0",
"mocha": "^5.0.0",
"uuid": "^3.2.1"
},
"optionalDependencies": {
Expand Down
20 changes: 9 additions & 11 deletions packages/google-cloud-vision/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ const vision = require('@google-cloud/vision');
const client = new vision.ImageAnnotatorClient();

// Performs label detection on the image file
client
.labelDetection('./resources/wakeupcat.jpg')
.then(results => {
const labels = results[0].labelAnnotations;

console.log('Labels:');
labels.forEach(label => console.log(label.description));
})
.catch(err => {
console.error('ERROR:', err);
});
async function main() {
const [result] = await client.labelDetection('./resources/wakeupcat.jpg');
const labels = result.labelAnnotations;
console.log('Labels:');
labels.forEach(label => console.log(label.description));
}
main().catch(err => {
console.error('ERROR:', err);
});
// [END vision_quickstart]

0 comments on commit d55eec2

Please sign in to comment.