-1

Hi im trying to get rest api data on html page by javascript fetch but i cant be able to fetch url categoryId can anyone help me out. Ill be so thank full of them.this is my Html page where i fetching my data

This is my rest controller from where i m getting my data

2 Answers2

-1

What error do you get?

I guess you have categoryId defined somewhere, so you should try something like this:

fetch(`/api/get_productc/${categoryId}`).then(...)

Be aware that there is a backtick around ( ` ) and $ sign before categoryId.

Dharman
  • 30,962
  • 25
  • 85
  • 135
-1

As im already fetch my data and in that data i have my catogeryId so i just take it out from that in this way onclick="productBrandDataById('+data[i].catogeryId+')">' Then i just fetch my data with this catogeryId like this fetch('/api/get_productc/'+catagoryId) then ill use it.