Undefined key when refreshing the page in next

const Product = () => {

const router = useRouter()


useEffect(() => {
 
    setParam({
        key:router.query.key,
        url:router?.query?.url || 'sheet',
    })
    getComment()
    ProductColor()
    getProd()
    getQuestion()
}, []);


const [prod, setProd] = useState({});
const [loading, setLoading] = useState(false);
const [param, setParam] = useState({key:'' , url:'sheet'});
const [question, setQuestion] = useState([]);
const [productcolor , setProductColor] = useState([]);
const [comment , setComment] = useState([]);
const [sort , setSort] = useState('new'); 
const [sortt , setSortt] = useState('new');
const [limit , setLimit] = useState(10);
const [limitt , setLimitt] = useState(10);
const [lm , setLm] = useState(false);
const [ld , setLd] = useState(false);


async function getProd(){
    setLoading(true)
    await axios.get(`${baseUrl()}/products/one/${param.url}/${param?.key || router?.query?.key}`)
    .then(res => {
    console.log(res);
        setLoading(true)
        if(!res?.data?.code && res.data.Product){
            setProd(res.data.Product)
        }
    })
    .catch(err => {
        setLoading(false)
        console.log(err);
        setProd(null)
    })
} 


async function getQuestion(s=sortt ,v=limitt){
    setLoading(true)
    setLd(true)


    await axios.get(`${baseUrl()}/products-q-a/${param.url}/${param?.key || router?.query?.key}?offset=0&limit=${v}&sort=${s}`)
    .then(res => {
       localStorage.setItem('key', 'url');
        setLoading(false)
        if(!res?.data?.code && res.data){
            //TODO
            setQuestion(res.data)
            setLd(false)
        }
    })
    .catch(err => {
        setLoading(false)
        console.log(err);
        setQuestion([])
    })
} 

If you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my questionIf you can, please answer my question