Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
Using Fetch to gather information from a Backend API?

In my backend (Ruby) I call a translation API, which returns me translated text. I need to then display this translated text when a User clicks on my TranslationButton.vue Component, I don't know to correctly reach into my Backend API via fetch. How does one discover the correct endpoint to use, when we are referring to a 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
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Have a route setup for your make_request method. Then hit that route from your front end.

i.e. fetch("localhost:3000/make_request?maybe_some_query_param=whatever_you_are_translating") and the rest of what you have looks good.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda