I’ve seen naming endpoints in sveltekit with .json.js. Why? .js should be enough, right?
>Solution :
It’s an old convention from earlier days to double the extension with the format of the returned data (data.json.js, data.xml.js) but is no longer used. I believe before it would even put the correct headers based on the extension, but think that is no longer the case.
You can of course still do this to make it clear to consumers what they will get back:
// I know I will get a json object from this because it says so in the name
const res = await fetch('something/products.json');