Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
How can I send data on a get and receive a return?

I have to send this data in a get request but I don't know how to do it. Can you help me?

const ROUTE = "public/v1/route";

export async function showRoute(
  flow: string,
  token: string
): Promise<RouteParams> {
  const response = await client.get(ROUTE);
  return response.data;
}
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

I think what you're looking for is the Fetch-API. For example,

const ROUTE = resourcePath + '?' + new URLSearchParams({ ...params })

fetch(ROUTE) // sends a GET request
  .then((res: Response) => res.json() as MyExpectedDataType) // parses JSON response content
  .then((data: MyExpectedDataType) => {
    // do something with data
  })
  .catch(err => {
  })

// or
async function showRoute(): Promise<Something> {
  try {
    const res: Response = await fetch(ROUTE)
    const data = await res.json() as MyExpectedDataType
    // do something with data
  }
  catch (err) {
  }
}

fetch returns a Promise type on which you can chain asynchronous callbacks using .then and handle errors with .catch and .finally. You can also pass request method, headers, body content etc. as an optional second argument to fetch, see the documentation.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use async/await or .then() promise chaining:

import {showRoute} from './path-to-showRoute'

showRoute(/* params */).then(data => sendGetRequest(data))

//or

async function sendRouteInfo(){
  const routeData = await showRoute(/* params */)
  if (routeData) sendGetRequest(routeData)
}

PS: sendGetRequest is a mock function which simply sends a get request using axios or fetch

about 4 years ago · Juan Pablo Isaza Denunciar

0

axios.get(${URL}) .then(response => console.log(response.data) .catch(err)=> console.log(err)


That is when you are using axios (npm i axios) then import it

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda