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 route example in docs doesn't seem to work #814

Open
yangkennyk opened this issue Jul 2, 2024 · 5 comments
Open

api route example in docs doesn't seem to work #814

yangkennyk opened this issue Jul 2, 2024 · 5 comments
Assignees
Labels
help wanted Looking for assistance on this issue improve documentation Enhance existing documentation. planned Features or content that are planned but not yet in progress.

Comments

@yangkennyk
Copy link

Describe the bug

I've been frustratingly trying to understand why I can't seem to get this example from the docs to work.

https://docs.solidjs.com/solid-start/building-your-application/api-routes

routes/api/product/[category]/brand-[brand].ts

import type { APIEvent } from "@solidjs/start/server";
import store from "./store";

export async function GET({ params }: APIEvent) {
  console.log(`Category: ${params.category}, Brand: ${params.brand}`);
  const products = await store.getProducts(params.category, params.brand);
  return products;
}

Your Example Website or App

https://stackblitz.com/edit/github-grada5-j81cuh?file=src%2Froutes%2Fapi%2Fproduct%2F%5Bcategory%5D%2Fbrand-%5Bbrand%5D.ts

Steps to Reproduce the Bug or Issue

From my understanding loading the following api route should work but I just get 404.

/api/product/tools/brand-dewalt

Expected behavior

I expected the api route to return

{
   "category":  "tools",
   "brand": "dewalt"
}

but I just get 404 on the route.

do I have a misunderstanding of how that route should work?

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

@ryansolid ryansolid transferred this issue from solidjs/solid Jul 3, 2024
@ryansolid
Copy link
Member

I don't believe we support partial params that way. You'd need to have a routes/api/product/[category]/[brand].ts route and then use matchFilters to get the specific brand-____ format.

@yangkennyk
Copy link
Author

I don't believe we support partial params that way. You'd need to have a routes/api/product/[category]/[brand].ts route and then use matchFilters to get the specific brand-____ format.

So is the example in the docs incorrect?

https://docs.solidjs.com/solid-start/building-your-application/api-routes

image

@ryansolid
Copy link
Member

Yes I'm pretty sure it is. Sorry I missed the URL there. I will move this to the docs repo. Thanks

@ryansolid ryansolid transferred this issue from solidjs/solid-start Jul 10, 2024
Copy link

stackblitz bot commented Jul 10, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@LadyBluenotes LadyBluenotes added help wanted Looking for assistance on this issue improve documentation Enhance existing documentation. labels Jul 18, 2024
@atilafassina atilafassina added the planned Features or content that are planned but not yet in progress. label Sep 1, 2024
@atilafassina
Copy link
Member

Thanks for pointingit out! I added the planned label so we can address this as early as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Looking for assistance on this issue improve documentation Enhance existing documentation. planned Features or content that are planned but not yet in progress.
Projects
None yet
Development

No branches or pull requests

5 participants