Skip to content
Advertisement

Pass multiple values to a param in getStaticPaths() in nextjs

I want to have two routes

  1. /midterm/cs611
  2. /finalterm/cs611

All i am trying to do is when i hit endpoint /midterm/cs611 it should display different content and when it hits to /finalterm/cs611 it should display different content. But i end up with correct results when hitting /finalterm/cs611 and when i hit /midterm/cs611 it shows 404 page.

If i replace like ‘midterm’ || ‘finalterm’, i see 404 page for finalterm and correct results for midterm.

Here i have my code

enter image description here

Here is the result hitting /midterm/cs611 enter image description here

Here is the result while hitting /finalterm/cs611 enter image description here

Advertisement

Answer

In your case exam_type is always “finalterm” as you use || (or) operator. It is not going to second option i.e. “midterm”. You can see finalterm route because you wrote that first, if you write midterm before finalterm you will see midterm route.

If you want two different routes, then you have to define both the routes separately instead of || (or) operator.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement