What exactly was the trace?
Did you see the execution start in the Appwrite console?
sorry, I have deleted the function and rewrote it using the Deno SDK. But what does happen on every script I write is, if it throws and error, I will see only an "Internal Server Error" message in the Error tab of the appwrite function's dashboard.
for the error I was having the error message was empty. The only information I had was that it happened in the function that tries to make a request to execute the function I requested in the appwrite's api.
gonna create a function to reproduce the issue for ya
it didn't work with the Deno's SDK either though, I had to do a workaround that would cost me more one request xD
Just an example
sorry for taking too long
/*
'req' variable has:
'headers' - object with request headers
'payload' - request body data as a string
'variables' - object with function variables
'res' variable has:
'send(text, status)' - function to return text response. Status code defaults to 200
'json(obj, status)' - function to return JSON response. Status code defaults to 200
If an error is thrown, a response with code 500 will be returned.
*/
export default async function (request: any, response: any) {
throw new Error(
'Environment variables are not set. Function cannot use Appwrite SDK.',
)
}
and this is what I get in the errors tab
if I don't catch the error and send it in the response, I'll have no idea of what went wrong xD
For now, it's best to always make sure you catch exceptions and return a response
How did you initialize and deploy your function?
appwrite init function
appwrite deploy function
one important thing I gotta ask you though is: do you know why the headers variable may be empty?
I tried Deno and PHP SDK's
I always get an empty array
Yes, they're always empty
I created a function to receive updates from Stripe webhook but I need the stripe-signature header to confirm the message belongs to Stripe
mmm
guess I gonna need to attach it to the body in the proxy layer then
Yes. Here's one that does that: https://github.com/BoolCode/appwrite-funcover
yeah, I just saw yours after creating mine XD https://github.com/ssa-web-solutions/appwrite-functions-proxy Not as professional as yours but works (it's lacking an auth layer though)
This isn't mine btw. It's made by byawitz. Mine isn't as good 😅
XD
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...