Calling a netlify function inside another netlify function


I am a third year CS student who have been testing out netlify and faunadb during my christmas vacation. I have created two separate netlify functions, one getting price information from a crypto api, and another that gets the user data from faunadb.

My site is not in production, so only testing in dev-mode.

Previously it was the client who managed and merged the different data sources together, but i wanted to try to move this logic to one single endpoint/function, thus i just cut out the block of code, calling the price-api, from my react component, to my “getUserData” netlify function. THis block starts after the //TODO comment. Both functions work as expected before the refactoring.

What am i doing wrong?

This is the error message i get now:

Request from ::1: GET /.netlify/functions/getUserData
coins:  [ 'bitcoin', 'thorchain' ]
error TypeError: fetch2 is not a function
    at Object.exports.handler (/Users/***********/WebstormProjects/AssetDash/assetdash/src/functions/getUserData.js:40:23)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

This is a code snippet:

import faunadb from "faunadb";
const fetch = require("node-fetch");


const q = faunadb.query;

const dbSecret = process.env.FAUNADB_SERVER_SECRET;

if (!dbSecret) {
    "Fant ikke credentials til databasen. Du må sette miljøvariabelen FAUNADB_SERVER_SECRET"

//Dette er et endepunkt
exports.handler = async (event) => {
  try {
    const client = new faunadb.Client({
      secret: dbSecret,
      domain: "",

    const responseFromDb = await client.query(
        q.Lambda((x) => q.Get(x))

    // funker ikke å bruke fetch her. Hva er feil? egen måte å kommunisere med functions internt?
    let cryptos = await[0].data.cryptos;
    let coins = [];
    cryptos.forEach((coin) => coins.push(;

    console.log("coins: ", coins);
    const res = await fetch(
      "/.netlify/functions/cryptoFunctions?coins=" + coins
    console.log("res:", res);

    return {
      statusCode: 200,
      body: JSON.stringify([0].data),
  } catch (error) {
    console.log("error", error);
    return {
      statusCode: 500,
      headers: {
        "Content-Type": "application/json",
      body: JSON.stringify(error),

While I don’t find a reference to fetch2 in your code so I don’t know where that’s coming from, but

this is incorrect.

In browser, you can use a relative URL and the browser can append the value and send the request to the correct URL, but AWS lambda can’t do that. You’d have to use absolute URL in there. So, it should be like:

"" + coins`

(or you could use process.env.URL)