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

380
Vistas
Fetch: HTTP GET Showing data not working via web api consuming gRPC

I'm trying see in console some data from a http Get method but it doesn't work, showing me error 400 and Idk how I get is errors... I did with the post method and it works well

I'm also trying to do authentication with bearer tokens but idk if this is correct

This is the fetch get method:

function getUsers() {
    fetch(uri_3_2, {
        headers: {
            'Accept': 'application/json',
            'Content-type': 'application/json',
            'Authorization': `Bearer ${localStorage.getItem("key")}`, 
        }
        //the localStorage.getItem("key") is a key I have when I first to other fetch call,
        //so this getUsers() is calling after the first fetch I have
        
    })
        .then(response => response.json()) 
        .then(data => _displayItems(data))
        .catch(error => console.error('Unable to get Users.', error));
}


function _displayItems(data) {
    console.log(data.Email); //undefined
    console.log(data.Username); //undefined
    console.log(data); //this works but don't show the data, I have so it gives me error...
}

I think this one is correct but I will show anyway Controller method

        [HttpGet("getAllUserInfo_2"), Authorize]             //message is empty but it works 
        public async Task<ActionResult<ListUsersResponse>> GetAll_2(MessageRequest message)
        {
            var results = await _userClient.GetAllUsersAsync(message);

            return Ok(results);
        }

gRPC service

public override Task<ListUsersResponse> GetAllUsers(MessageRequest request, ServerCallContext context)
        {
             ListUsersResponse response = new ListUsersResponse();

             var query = from emp in _context.Users_4
                select new ListUserResponse()
                {
                   Username = emp.Username,
                   Email = emp.Email
                };

             response.LstUsers.AddRange(query.ToArray());

             return Task.FromResult(response);
        }

about 4 years ago · Juan Pablo Isaza
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