One challenge I am facing is how to correctly access my Backend API in Ruby to fetch translated text from a translation service. Specifically, I am unsure about the correct endpoint to use when making the backend API call.
Messages.vue
methods {
loadTranslations() {
fetch('#whatgoeshere')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
console.log(myJson)
});
},
}
request.rb
def make_request
response = Faraday.post('https://api.deepl.com/v2/translate', auth_key: 'authkeyhere', text: @final_ticket, target_lang: 'DE', source_lang: 'EN')
if response.status == 200
body = response.body
translated_text = body.split('"')[-2]
return translated_text
else
raise InvalidResponseError unless response.success?
end
end