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

85
Vistas
ReactJS getting results from a Promise

In my sagas, I am sending user credentials to the backend

const request = client.post('api/JwtAuth/GenerateToken', {UserName: action.username, Password: action.password})
console.log(request) 

client looks like this

import axios from "axios"

const client = axios.create({
    baseURL: 'https://localhost:5001/',
    timeout: 600000000000,
    headers: {
        ContentType: 'application/json'
    }
})

export default client

Chrome Browser console

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

what is your question? If the question why are you seeing Promise on the console? That's because you are dealing with promises, either use .then

client.post().then(res => console.log(res.data)).catch(err => console.log(err))

or async await syntax

await client.post()
about 4 years ago · Juan Pablo Isaza Denunciar

0

  const request = client.post('api/JwtAuth/GenerateToken', {UserName: 
    action.username, Password: action.password})

  request.then(response => {
    // the response body can be accessed through the "data" property
    console.log(response.data)
  })
  console.log(request) 

UPDATE:

You are doing this inside a saga, right? If so, the best way to get the request response data is to use the call effect. Import it from redux-saga/effects, and get the response like this:

  const response = yield call(
    client.post,
    'api/JwtAuth/GenerateToken',
    { UserName: action.username, Password: action.password }
  )

  console.log(response.data)
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