Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

377
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!