Although this question may be considered old, I have a workaround that I personally utilize. By having one GET method and executing different methods based on the parameters sent to it, you can achieve the desired functionality. Here are some examples of fetch calls:
// Fetch to hit get1
async function getReport1() {
const response = await fetch(`/api/delayreports?get=1`, {
method: 'GET'
});
}
// Fetch to hit get2
async function getReport2() {
const response = await fetch(`/api/delayreports?get=2`, {
method: 'GET'
});
}
Subsequently, consider the server endpoint logic:
export async function GET({ url }) {
const get = url.searchParams.get('get')
if (get === 1) {
console.log('you hit get 1')
}
if (get === 2) {
console.log('you hit get 2')
}
}
This approach allows for flexibility with various parameters. Personally, I often use an ID parameter; if the ID is not null, then execute function A, otherwise execute function B.