how to send url from one to another ejs file

Viewed 18

i have 1 category template and i have nested categories. For access that nested categories in categrouse this method: sub_category.ejs :

<div id="sub-category-box" class="py-4  ">
    <% subCategories.forEach(function(subCategorie, index){ %>
    <h1 class="display-5 py-2"><%- subCategorie.name %></h1>
    <div class="row">
        <img src="../public/images/<%-subCategorie.image %>"  alt="">
    </div>
    <p class="py-3"><%- subCategorie.page_description %></p>
    <button class="btn btn-primary"><a href="<%- subCategorie.id%>" class="text-reset text-decoration-none">More Info</a></button>
    <div class="border-warning border-3 border-bottom py-2"></div>
    <% }) %>

sub_category.js:

const express = require('express')
const router = express.Router()
const axios = require('axios')


    router.get('/:sub_category', async (req, res, next) =>{
        const deneme = await axios.get(`api/categories/parent/${req.params.sub_category}?secretKey=[secretKey]`)
        
        
        
        res.render('sub_category', {subCategories: deneme.data })
        console.log(req.params.sub_category)
        
        return next()
    })

but i have to reach products from another endpoint with the url cames from category endpoint, when i click the button i get the url but it shows on sub_category page, i want to show it on products.ejs/js. how can i change endpoint and redirect it to products page instead of staying in sub_category (it has to redirect to category at the end of subcategory).

0 Answers
Related