token 분기처리 추가
This commit is contained in:
@@ -128,20 +128,26 @@ async function translateMain(text:string, arg:{from:string, to:string, host:stri
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(db.translatorType === 'deeplX'){
|
if(db.translatorType === 'deeplX'){
|
||||||
const body = {
|
const body = JSON.stringify({
|
||||||
text: [text],
|
text: [text],
|
||||||
target_lang: arg.to.toLocaleUpperCase(),
|
target_lang: arg.to.toLocaleUpperCase(),
|
||||||
source_lang: arg.from.toLocaleUpperCase()
|
source_lang: arg.from.toLocaleUpperCase()
|
||||||
|
})
|
||||||
|
let url = db.deeplXOptions.url;
|
||||||
|
let headers = {
|
||||||
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
let url = db.deeplXOptions.url
|
|
||||||
|
// token이 비어있지 않으면 headers에 Authorization 추가
|
||||||
|
if(db.deeplXOptions.token.trim() !== '') {
|
||||||
|
headers["Authorization"] = "Bearer " + db.deeplXOptions.token;
|
||||||
|
}
|
||||||
|
|
||||||
const f = await globalFetch(url, {
|
const f = await globalFetch(url, {
|
||||||
headers: {
|
method: "POST", // 요청 메소드 추가
|
||||||
"Content-Type": "application/json",
|
headers: headers,
|
||||||
"Authorization" : "Bearer " + db.deeplXOptions.token
|
|
||||||
},
|
|
||||||
body: body
|
body: body
|
||||||
})
|
})
|
||||||
|
|
||||||
if(!f.ok){
|
if(!f.ok){
|
||||||
return 'ERR::DeepLX API Error' + (await f.data)
|
return 'ERR::DeepLX API Error' + (await f.data)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user