custom route
Unanswered
Southeastern blueberry bee posted this in #help-forum
Southeastern blueberry beeOP
.
36 Replies
Southeastern blueberry beeOP
@aardani
@deathlybower959
please describe your confusion
@aardani please describe your confusion
Southeastern blueberry beeOP
how to make a custom route?
i told u in general
here is your custom route
in order to access a db, thats a separate thing
but this is how you would create a dynamic route
@deathlybower959 in order to access a db, thats a separate thing
Southeastern blueberry beeOP
through api
so
a users enters
then the code gets the "bacon"
run its too api and see if its in db
if not
else
404
it shows the user
it goes to that dynamic route, and using the dynamic text "bacon", it queries your api to either get the data, or return null
if null then return 404, otherwise show user
if null then return 404, otherwise show user
yes
thats what Ardanis code had showed here
const data = await getData(params.user)
if(data) return <>Hello {data.username}</>
if(!data) redirect('/not-found')the getData function was a query to your api, which PASSED in data
@Southeastern blueberry bee https://website.com/bacon
in this case, params.user represents this dynamic part of the url
@deathlybower959 thats what Ardanis code had showed here
js
const data = await getData(params.user)
if(data) return <>Hello {data.username}</>
if(!data) redirect('/not-found')
Southeastern blueberry beeOP
redirect is not defined
1.) You didnt import it
2.) i would again, suggest learning nextjs or even whatever language you are writing it in, because it doesnt seem like you have the fundamentals down
2.) i would again, suggest learning nextjs or even whatever language you are writing it in, because it doesnt seem like you have the fundamentals down
you are just jumping right into it
are you writing it in javascript or typescript?
Southeastern blueberry beeOP
tsx
i know ts and js
i just dont know next
@Southeastern blueberry bee redirect is not defined
i feel like if you knew ts then this would be pretty self explanatory. Im also assuming you use vscode, so it would also show you a mouse hover error, or in the problems console
but regardless, go watch a video on nextjs, or start learning it from the docs
@deathlybower959 i feel like if you knew ts then this would be pretty self explanatory. Im also assuming you use vscode, so it would also show you a mouse hover error, or in the problems console
Southeastern blueberry beeOP
i know what the error means
i was just saying
the error