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

379
Visualizações
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 à 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