Skip to content

Commit

Permalink
fix(service/microsoft): remove the explicitly specified content-length
Browse files Browse the repository at this point in the history
  • Loading branch information
yin1999 committed Aug 25, 2023
1 parent d5785fe commit eff2a42
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/modules/services/microsoft.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { TranslateTaskProcessor } from "../../utils/task";

export default <TranslateTaskProcessor>async function (data) {
const req_body = JSON.stringify([
{
text: data.raw,
},
]);
const reqBody = JSON.stringify([{ Text: data.raw }]);

const xhr = await Zotero.HTTP.request(
"POST",
`https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=${data.langto}`,
{
headers: {
"Content-Type": "application/json; charset=utf-8",
Host: "api.cognitive.microsofttranslator.com",
"Content-Length": req_body.length,
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": data.secret,
},
responseType: "json",
body: req_body,
body: reqBody,
},
);
if (xhr?.status !== 200) {
Expand Down

0 comments on commit eff2a42

Please sign in to comment.