# Netlify function javascript fetch not working

**URL:** <https://answers.netlify.com/t/netlify-function-javascript-fetch-not-working/83727>\
**Category:** Support\
**Tags:** lambda-functions, edge\_functions, netlify-newbie, building, deployment\
**Created:** [January 22, 2023, 7:50pm UTC](https://answers.netlify.com/t/netlify-function-javascript-fetch-not-working/83727 "2023-01-22T19:50:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PabloBerry44](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/pabloberry44/32/45986_2.png) [@PabloBerry44](https://answers.netlify.com/u/PabloBerry44)\
**Post date:** [January 22, 2023, 7:50pm UTC](https://answers.netlify.com/t/netlify-function-javascript-fetch-not-working/83727/1 "2023-01-22T19:50:47Z")

</div>

Hello,  
I am trying to call API in Netlify function and pass data to the client. I tried **fetch** and **axios** but still have problems with getting the function to work.

To make my problem more simple I switched to API with no key and made sure that it works when called on client side.

 ![problem](https://global.discourse-cdn.com/netlify/original/3X/7/5/759d9df4862be2637a3394ea6d748d4bab440943.png)

> **[Netlify](https://app.netlify.com/sites/delightful-cendol-5b49a7/overview)**
>
> Start building the best web experiences in record time

[https://delightful-cendol-5b49a7.netlify.app/](https://delightful-cendol-5b49a7.netlify.app/)

I would be super grateful if someone help me

---

<div class="post-metadata">

**Author:** ![whitep4nth3r](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/whitep4nth3r/32/52581_2.png) [@whitep4nth3r](https://answers.netlify.com/u/whitep4nth3r)\
**Post date:** [January 23, 2023, 8:53am UTC](https://answers.netlify.com/t/netlify-function-javascript-fetch-not-working/83727/2 "2023-01-23T08:53:42Z")

</div>

Hey @PabloBerry44 — have you installed node-fetch and does it appear in your package.json file?

The error on the screenshot is reporting that you don’t have node-fetch installed.

---

<div class="post-metadata">

**Author:** ![PabloBerry44](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/pabloberry44/32/45986_2.png) [@PabloBerry44](https://answers.netlify.com/u/PabloBerry44)\
**Post date:** [January 23, 2023, 4:27pm UTC](https://answers.netlify.com/t/netlify-function-javascript-fetch-not-working/83727/3 "2023-01-23T16:27:31Z")

</div>

Thank you @whitep4nth3r for your answer. I didn’t install node-fetch at this point and did it later. I ran into other errors and tried axios one more time and it actually worked for me.

Here is a screenshot of working Netlify function that calls API.

 ![es](https://global.discourse-cdn.com/netlify/original/3X/2/9/29dc40e8f7a8a5859b41396ad3e03449145fb1d6.png)

Please let me now if this way of calling API is not deprecated and up to todays standards.

Thank You 🙂

---

<div class="post-metadata">

**Author:** ![whitep4nth3r](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/whitep4nth3r/32/52581_2.png) [@whitep4nth3r](https://answers.netlify.com/u/whitep4nth3r)\
**Post date:** [January 23, 2023, 4:55pm UTC](https://answers.netlify.com/t/netlify-function-javascript-fetch-not-working/83727/4 "2023-01-23T16:55:40Z")

</div>

Yep, using axios is perfectly valid!

I can take a guess at the errors you came across when using node-fetch. For anyone else that finds this blog post via a Google search or whatever, this blog post will help diagnose some issues!

> **[How to make a fetch request using node-fetch v3](https://www.netlify.com/blog/how-to-make-a-fetch-request-using-node-fetch-v3/)**
>
> Make a fetch request using node-fetch v3 within Netlify Serverless Functions.
