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

767
Visualizações
fetch from javascript and node-fetch from node.js, what are the differences

I am recently learning how to code on udemy, and I encountered a problem. when we fetch api we can fetch from the browser and we can also use node-fetch from node.js. I want to know what's the difference between them. Can we directly fetch api from external server not through the web server.if so what should we fetch data from node.js?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Node.js does not come with the fetch libriary per default. Fetch API does only exist in webbrowsers under window.fetch. Node-fetch is just a lightweight libriary containing this webbrowser fetch.

That said to install and use fetch in Node.js use following commands:

npm i node-fetch

Then to import it use

import fetch from 'node-fetch';

See the official npm package of node-fetch.

The Fetch API is very basic. If you have to use Http Requests in a Node.js app I would recommend using axios.

about 4 years ago · Juan Pablo Isaza Relatório

0

We can try to fetch the external API from the browser. That can give Cross Origin Resource Sharing (CORS) errors if the endpoint does not want you to access their API from a browser

Then you can write a proxy that accesses the external API from the server, that will be allowed regardless of CORS settings

So accessing an API from NODE will always work (assuming no need for authentication) and fetch from browser may or may not work directly.

NOTE: node-fetch is not native to node

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