I am trying establish connection between my chrome extension and text analytics API. I have created background.js to deal with connection after extension is installed to chrome but it's throwing error code: Failed to load resource: the server responded with a status of 404 ()
How can I establish connection between extension and Azure TA API?
CodePudding user response:
There's a JavaScript library you can use: Azure Text Analytics client library for JavaScript. The GitHub repo has a lot of examples, like this one for detecting the language:
const documents = [
"This document is written in English.",
"Este es un document escrito en Español.",
"这是一个用中文写的文件",
"Dies ist ein Dokument in deutsche Sprache.",
"Detta är ett dokument skrivet på engelska."
];
const client = new TextAnalyticsClient(endpoint, new AzureKeyCredential(apiKey));
const results = await client.detectLanguage(documents);