I tried doing something like this in my endpoint routes/users.json.ts :
import * as api from '$lib/api'
export async function get({ query, locals }) {
const response = await this.fetch('static/data/customers.json')
return {
status: 200,
body: {
data: response
}
}
}
my static folder is located in the routes folder.
I got this error:
...
TypeError [ERR_INVALID_URL]: Invalid URL: /static/data/customers.json
at onParseError (internal/url.js:259:9)
at new URL (internal/url.js:335:5)
at new Request (file:///home/nkostic/code/example/node_modules/@sveltejs/kit/dist/install-fetch.js:1239:16)
...
What am I missing ?
The important thing is that it has to be static json files.