Search code examples
apivue.jsslug

Vue: How can i use the data gotten from APi as Slug


Presently I have built my app, it is working perfectly, however, I do not want the url to show my id, for instance my url is presently www.example/product/23. Instead of that, I want to have www.example/product/product-name.

The API in which the data is coming from is endpointURL.com/product/id In my Vue router

{
  path: "/product/:id",
  name: "product", 
  component: product
},

If I change the path /product/:slug, it generates an error.

I really need it to change the url to /slug.


Solution

  • To solve this case, i had to create an endpoint from the backend ,e.g endpointURL.com/product/slug