First of all, my directory looks like this (simplified):
website/
index.html
files/
script.js
api/
site.html
index.html is using script.js.
In script.js I want to fetch site.html
script.js:
fetch('./api/site.html')
.then(response => {
response.json()
.then(
// code
);
})
And instead of fetching example.com/website/api/site.html it fetches example.com/api/site.html
What should I change in fetch without specifying name of parent directory?