Reputation: 73
I am using this API:'/api/categories/${catID}/items/addItem/'
from my spring boot java to enter some data to item table which has relation with category table.
Now in javascript, I used ajax: $.ajax({ url: '/api/categories/${catID}/items/addItem/', type: "POST", contentType: "application/json", etc
Now I get a problem from the url and cannot read the value of ${catID}
This is the real API: "/api/categories/{categoryId}/items/addItem" I have looked inside the site but the solution does not work with me. Now how can I pass a value of a variable if the variable are in the middle.
Thanks in advance.
Upvotes: 0
Views: 349
Reputation: 327
You're trying to use template literals which require backticks(`) instead of single quotes(').
url: `/api/categories/${catID}/items/addItem/`
Upvotes: 4