#Can a cron triggered function have a default method and set of query params?
4 messages · Page 1 of 1 (latest)
Hmm not this specifically, but you can check the cause of execution and then either duplicate your code, find smart way to re-use it, or override values coming into the function. For example, that could look like
export default async ({ req, res, log, error }) => {
if(req.headers['x-appwrite-trigger'] === 'schedule') {
req.method = 'DELETE';
req.path = '/my-custom-path';
// ...
}
// Your code ...
}
Personally I wouldn't recommend to go with code snippet above, feels like a hack. I would recommend to extract data from req above the if, and inside, override your variables.
I currently have a few Functions I'd love to combine into one, which I could do only if there were some way to have multiple different schedules on one Function with different paths