Support Forums

Netlify Function with FaunaDB Query failed: Ref refers to undefined index

Help, I can’t figure out what went wrong.
Netlify Function with FaunaDB Query failed: Ref refers to undefined index

The outcome of deployed function is different to the outcome of localhost.
Test site: https://1028--droplets.netlify.app/.netlify/functions/getUser?id=nik

Outcome: /getUser?id=nik

{"build":1028,"message":"Query failed: Ref refers to undefined index 'users_id'"}

locahost: /getUser?id=nik



"use strict";

const { handle, json, message } = require('./utils/main');
const { q, client, getFaunaErrorMessage } = require('./utils/fauna');
const { env } = process, e=env;

const build=1028;

exports.handler = handle(async function(event,context) {

  { id } = event.queryStringParameters;

  return client(
    q.Get(q.Match(q.Index("users_id"), id||'' ))
    return json(500,{
      message:'Query failed: '+getFaunaErrorMessage(error)



>netlify deploy --alias=1028
Deploy path:        \_site
Functions path:     \_functions
Configuration path: \netlify.toml
Deploying to draft URL...
√ No cached functions were found
√ Finished hashing 10 files and 2 functions
√ CDN requesting 0 files and 2 functions
√ Finished uploading 2 assets
√ Deploy is live!

Logs:              https://app.netlify.com/sites/droplets/deploys/619c4c6cb61e243bc617c82e
Website Draft URL: https://1028--droplets.netlify.app

FaunaDB: Running Shell Query with Server key
Outcome just fine.

Get(Match(Index("users_id"), "nik"))

    data: [Collection("users")]
    data: [Index("users_id")]
    ref: Ref(Collection("users"), "315756321428210252"),
    ts: 1637387544000000,
    data: {
      id: "nik"

I wonder what went wrong?

The better the post - the faster the answer.

Hi @nikahmad,

When I tried the link you shared above, I got this:


I wonder if something changed meanwhile?