Skip to content

Commit

Permalink
Merge pull request #39 from aahill/ta-quickstart-update
Browse files Browse the repository at this point in the history
[Text Analytics] Removing environment variables from code
  • Loading branch information
aahill authored Mar 6, 2020
2 parents c2fd699 + 931e13f commit 6517fff
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions Samples/textAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,12 @@ const TextAnalyticsAPIClient = require("@azure/cognitiveservices-textanalytics")
// </constStatements>

// <keyVars>
const key_var = 'TEXT_ANALYTICS_SUBSCRIPTION_KEY';
if (!process.env[key_var]) {
throw new Error('please set/export the following environment variable: ' + key_var);
}
const subscription_key = process.env[key_var];

const endpoint_var = 'TEXT_ANALYTICS_ENDPOINT';
if (!process.env[endpoint_var]) {
throw new Error('please set/export the following environment variable: ' + endpoint_var);
}
const endpoint = process.env[endpoint_var];
const key = '<paste-your-text-analytics-key-here>'
const endpoint = `<paste-your-text-analytics-endpoint-here>`;
// </keyVars>

///////////////////////////////////////////
// Entrypoint for sample script //
///////////////////////////////////////////

// <authentication>
const creds = new CognitiveServicesCredentials.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': subscription_key } });
const creds = new CognitiveServicesCredentials.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': key } });
const textAnalyticsClient = new TextAnalyticsAPIClient.TextAnalyticsClient(creds, endpoint);
// </authentication>

Expand Down

0 comments on commit 6517fff

Please sign in to comment.