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

759
Views
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 answers
Answer question

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 Report

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 Report
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!