fix: change DeepL API calls config

This commit is contained in:
2026-04-28 12:30:46 +04:00
parent 7a168f54ff
commit be4c7ed421
+8 -2
View File
@@ -21,14 +21,20 @@ class Translator {
target_lang: target, target_lang: target,
text text
} }
const result = await axios.post(this.urlRequest, qs.stringify(data), { const result = await axios.post(this.urlRequest, {
text: Array.isArray(text) ? text : [text],
source_lang: origin,
target_lang: target,
}, {
headers: { headers: {
'content-type': 'application/x-www-form-urlencoded' Authorization: `DeepL-Auth-Key ${this.deeplKey}`,
'Content-Type': 'application/json'
} }
}) })
return result.data return result.data
} catch (error) { } catch (error) {
console.error('DeepL error:', error?.response?.data || error);
console.log('error', error) console.log('error', error)
} }
} }