Lately, I've been diving into learning NextJS API routes and NodeJS. While I have successfully grasped the concept of creating dynamic routes, there are a few hurdles I'm facing -
Let's take a look at my api/matches.js
file.
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
export default async function handler(req, res) {
const response = await fetch(`https://exampleapi.com/?&token=# `)
const jsonData = await response.json();
res.status(200).json(jsonData);
}
Now, I have another dynamic route in this API which retrieves matches based on a match slug, hence the file name /api/matches/[...matchslug].js
export default async function handler(req, res) {
const page = req.query.matchslug
const response = await fetch(`https://examleapi.com/?search[slug]=${page}&token=# `)
const jsonData = await response.json();
Although this dynamic route fetches results for a single match when querying matches/exampelmatch
, my goal is to figure out a way to
matches/examplematch1/examplematch2
where I can retrieve data for both examplematch1
and examplematch2
simultaneously.
I'm curious if such functionality is achievable and would love to explore it further.
Thank you for taking the time to read through this.