I have been working on this site and I have hit a wall. Basically I am supposed to list movies by genre, fetched from database. The genre should take me to another list based on the genre. Once a user clicks the movie from say 'action' genre it takes them to the movie details on another page.
This is the structure
Movies/ [moviesbygenrelist]/list
Everything works till there.
Moving on to the second dynamic page I cannot get values of first and second dynamic page
as below...
Movies/ [moviesbygenrelist]/[movie-slug]
I am statically generating the site
how can i get parameters of first page while on the second dynamic page
This is what i have,
I first call
let movieTypeID;
let movieSlug;
export async function getStaticProps({params}) {
movieTypeID=params.movietype;
movieSlug=params.movie;
}
my logic is i can access route parameters from getStaticProps but not in getStaticPaths so I call it first, instantiate the variables then pass them to getStaticPaths so I can make database calls using the variables since I am now a bit deep in the database. I cannot make calls without the dynamic parameters
I pass them like below
export async function getStaticPaths(movieTypeID, movieSlug) {
///only they come out as undefined
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…