fix: change DeepL API calls config
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user