Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
Use Link query data in getServerSideProps NextJS

I have a Link tag that redirects to another page along with a query item. What I want to do is use it in a getServerSideProps function in order to make an API call with the query item.

Here's what the source code looks like:

import Navbar from "../components/Navbar"
import Footer from "../components/Footer"
import ProductCard from "../components/ProductCard"

import { useRouter } from "next/router"
import axios from "axios"


export default function products({productList}){

    const router = useRouter()
    const {category} = router.query
    console.log(category)
    
    
    
    return (
        <>
            <Navbar />
            <div className="container-fluid p-0">
                <div className="container text-center">
                    <h1 className="display-3">Starters</h1>
                    <div className="container text-center">
                        <div className="row">
                            {productList.map((Product) => (
                                <ProductCard key={Product.ID} Product={Product}></ProductCard>
                            ))
                            }
                        </div>

                    </div>
                </div>
            </div>
            <Footer></Footer>
        </>
    )
}

export const getServerSideProps = async () => {
    const res = await axios.get(`http://192.168.0.112:3000/api/products/productShow`)
    return {
        props: {
            productList: res.data,
        },
    }
}

How can I use the category value inside getServerSideProps so I can append it to my GET request?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!