So I am trying to take full advantage of the new function capabilities via context.log & context.error but am running into issues with getting that to work.
Current Implementation
index.js
// I've tried both
module.exports = async function (req, res, log, error) {
// module.exports = async function ({ req, res, log, error }) {
...
log("blah blah blah")
...
}
I recieve this error
TypeError: log is not a function
package.json in case that matters
{
"name": "appwrite-function",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"node-appwrite": "^11.0.0",
}
}
I would also like to point out that the documentation for NodeJS Functions is different depending on where you look:
https://appwrite.io/docs/functions-develop vs https://github.com/appwrite/functions-starter/blob/main/node-16.0/src/index.js
I couldn't get the first example to work due to module errors around import so I just used the functions-starters. I am using appwrite-cli if that helps.
Appreciate any insight!
https://github.com/appwrite/functions-starter/blob/main/node-16.0/src/index.js
This is the pre-1.4 syntax
What version of the CLI are you using? (appwrite -v)
0.17.1
*The functions may have been originally templated via an older version of the cli/appwrite
that is really old...meant for Appwrite 0.14.x: https://github.com/appwrite/sdk-for-cli/blob/0.17.1/README.md
If you're on Appwrite 1.4.3, you should be using 4.1.0 of the CLI: https://github.com/appwrite/sdk-for-cli/blob/4.1.0/README.md
geez, you're not kidding. I thought npm i -g appwrite-cli would automatically pull the latest version but I guess not
Okay so when running npm i from WSL it would only ever pull v0.17.1...when I installed it from just a general windows terminal it did indeed pull v4.1.0 and that is reflected in WSL now
Can't wait till you guys sort out the Windows appwrite-cli bugs <:appwriteheart2:1073243188954935387>
I'll refactor the function to 1.4 syntax and report back
uhhh in general, i don't think npm i will upgrade your package
what bug?
I uninstalled appwrite-cli and then reinstalled it from both WSL and Default Windows Terminal...only the windows terminal pulled v4.1.0
I swear to god...if I've been using WSL this whole time because I was using an outdated appwrite-cli...
Yup, was fixed in 0.18.4.
Classic PEBCAK situation
Works now. I also missed the fact that my old functions were Read Only so I had to remake them entirely instead of simply updating the code
you do need to recreate the function 🧐
are you saying you just created a new deployment with the 1.4 syntax and it worked?
I don't believe I could get new deployments to work on the existing function (which was originally created before 1.4.x via CLI v0.17.1). Definitely could have been a me issue, but even after I updated the package.json and main.js files to the newer formats, it wasn't taking.
I ended up just creating an entirely new function which worked.
you can create new deployments, on old functions, but they must be in the old format. the new format will only be used on new functions created after upgrading to 1.4
That'd be why they weren't working! Out with the old, in with the new!
Recommended threads
- Excessive usage of cloud functions is sl...
I have made almost all my requests through cloud functions and jwt , due to security fears of a user editing a field he is not supposed to . This unfortunately...
- Dart Runtime as Function is missing
Hey guys, I set the _APP_FUNCTIONS_RUNTIMES to dart-3.10 and redeployed the appwrite stack but unfortunately the dart runtime doesnt show up. I copied the val...
- Go 1.25 runtime
So I'm trying to use go 1.25 for my functions and I can only find go-1.23 as a function runtime. So I did some searching and found https://github.com/appwrite/a...