From 6e80f8b176c9e208d95db396031c5a0890c7ab1b Mon Sep 17 00:00:00 2001 From: Winona Azure <38537084+wiazur@users.noreply.github.com> Date: Fri, 4 Oct 2019 18:37:08 -0700 Subject: [PATCH] Fixed typos, corrected some null values --- Samples/imageSearch.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Samples/imageSearch.js b/Samples/imageSearch.js index 90826f0..74e3093 100644 --- a/Samples/imageSearch.js +++ b/Samples/imageSearch.js @@ -11,20 +11,17 @@ const Search = require('azure-cognitiveservices-search'); const CognitiveServicesCredentials = require('ms-rest-azure').CognitiveServicesCredentials; // Add your Bing Search V7 subscription key to your environment variables. -let keyVar = process.env['BING_SEARCH_V7_SUBSCRIPTION_KEY'] +let subscriptionKey = process.env['BING_SEARCH_V7_SUBSCRIPTION_KEY'] -if (!process.env[keyVar]) { - throw new Error('please set/export the following environment variable: ' + keyVar); +if (subscriptionKey == null || subscriptionKey == "" || subscriptionKey == undefined) { + throw new Error('please set/export the following environment variable: ' + subscriptionKey); } -let serviceKey = process.env[keyVar]; - - /////////////////////////////////////////// // Entrypoint for sample script // /////////////////////////////////////////// -let credentials = new CognitiveServicesCredentials(serviceKey); +let credentials = new CognitiveServicesCredentials(subscriptionKey); let imageSearchApiClient = new Search.ImageSearchAPIClient(credentials); function sample() { @@ -258,5 +255,5 @@ function sample() { throw (err); }); } - +sample() exports.sample = sample;