Open 1c7 opened 1 year ago
刚跑通了, node 的例子,供参考,里面的魔法字符串挺多,如果可以,建议研发把这些常量改为枚举,比如 servicename region version 等
import { Service } from "@volcengine/openapi";
const accessKeyId = env.VOLC_ACCESSKEY;
const secretKey = env.VOLC_SECRETKEY;
const postBody = {
SourceLanguage: "en",
TargetLanguage: "zh",
TextList: ["hello world"],
};
const service = new Service({
host: "open.volcengineapi.com",
serviceName: "translate",
region: "cn-north-1",
accessKeyId,
secretKey,
});
const fetchApi = service.createAPI("TranslateText", {
Version: "2020-06-01",
method: "POST",
contentType: "json",
});
const rr = await fetchApi(postBody, {});
// [ { Translation: '你好世界', DetectedSourceLanguage: '', Extra: null } ]
console.log(rr.TranslationList);
@Otto-J 非常感谢!
https://www.volcengine.com/docs/4640/65067