Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API routes have to be inline exported function declarations #1587

Open
nnmrts opened this issue Jul 22, 2024 · 0 comments
Open

API routes have to be inline exported function declarations #1587

nnmrts opened this issue Jul 22, 2024 · 0 comments
Labels
vinxi related to vinxi

Comments

@nnmrts
Copy link

nnmrts commented Jul 22, 2024

Describe the bug

This works

export async function GET(...parameters) {
  console.log(parameters);

  return new Response("test", { status: 200 });
};

while this doesn't

const GET = async (...parameters) => {
  console.log(parameters);

  return new Response("test", { status: 200 });
};

export { GET };

Your Example Website or App

n/a

Steps to Reproduce the Bug or Issue

  1. Create the second code example as an API route.
  2. Observe it responding with this
{
  "statusCode": 500,
  "stack": []
}

Expected behavior

It should just work like the first code example. Internally, this library probably uses function names instead of named export names to determine the endpoint functions. It shouldn't.

Screenshots or Videos

No response

Platform

  • OS: macOS Sequoia
  • Browser: Chrome
  • Version: 1.0.6

Additional context

No response

@ryansolid ryansolid transferred this issue from solidjs/solid Jul 23, 2024
@ryansolid ryansolid added the vinxi related to vinxi label Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vinxi related to vinxi
Projects
None yet
Development

No branches or pull requests

2 participants