
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
- Error
I'm trying to get sellerId using account.get() in my appwrite function and this is the error message I'm getting: "Failed to send notification to seller 6865bf...
- Is there a timeframe for updating dart r...
Dart 3.5 is already one year old, and the following versions have introduced very important features for the language. Is there a roadmap or timeframe for when...
- Error
I'm trying to get sellerId using account.get() in my appwrite function and this is the error message I'm getting: "Failed to send notification to seller 6865bf...
