@Chris The error that you are seeing suggests that s
in the tryParseConnectionString
function is null
or undefined
. You should check how you are passing the connection string in your code.
How do I format a connection string for Azure Email Node JS file?
Chris
0
Reputation points
I am unsure how to unsure how to format the connection string. When I run the file it gives an error stating
“node_modules/@azure/communication-common/dist/index.js:250
const match = s.match(CONNECTION_STRING_REGEX);
^TypeError: Cannot read properties of undefined (reading 'match’)”
I am unsure on how this error is occurring and the demo provided on the website says nothing on how to format it.
// Copyright (c) Microsoft Corporation.
// TODO: update when connection string format is finalized
const CONNECTION_STRING_REGEX = /endpoint=(.*);accesskey=(.*)/i;
const tryParseConnectionString = (s) => {
const match = s.match(CONNECTION_STRING_REGEX);
if ((match === null || match === void 0 ? void 0 : match[1]) && match[2]) {
return { endpoint: match[1], credential: new coreAuth.AzureKeyCredential(match[2]) };
}
return undefined;
};
/**
* Returns an EndpointCredential to easily access properties of the connection string.
* @hidden
*
* @param connectionString - The connection string to parse
* @returns Object to access the endpoint and the credentials
*/
const parseConnectionString = (connectionString) => {
const parsedConnectionString = tryParseConnectionString(connectionString);
if (parsedConnectionString) {
return parsedConnectionString;
}
else {
throw new Error(`Invalid connection string ${connectionString}`);
}
};
Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
1,234 questions
Microsoft 365 and Office | Development | Office JavaScript API
1,066 questions
1 answer
Sort by: Most helpful
-
Pramod Valavala 20,656 Reputation points Microsoft Employee Moderator
2023-08-09T17:24:16.7966667+00:00