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

110
Visualizações
Proper use case for Request VS Response with Fetch/Axios

I am learning to create REST API's and use HTTP requests. It seems though that naming conventions for Request/Response is not consistent.

What I mean by all that is, many things I google regarding fetch requests. Use response as the variable name for fetch. EX: const response = await fetch('Someurlhere.com');

But if I am understanding correctly, that would be the request would it not? Response should be const response = await request.json();

I am really just trying to make sure I am understanding everything correctly in my head of if there is a reason why there are so many resources that use my first example, which to me seems like an improper use and will just confuse new learners like myself.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

But if I am understanding correctly, that would be the request would it not?

No. The request is what calling fetch triggers the browser to send to the URL. You pass the data about what the request should look like as arguments to fetch.

You could do that indirectly (which is rarely useful) by passing a Request object as an argument to fetch…

const request = new Request("http://example.com");
const response = await fetch(request);

… but fetch returns a promise that resolves as a Response.

Response should be const response = await request.json();

No. The promise returned from response.json() resolves as the result of parsing the response body as JSON.


You're confusing "the response" and "something inside the response" with "the request" and "the response"

about 4 years ago · Santiago Gelvez Relatório
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