[SOLVED] The function `users.updateLabels` is returning an empty error.
- 0
- Self Hosted
- Functions
- Users
Maybe it’s because of the beta (using Starter Cloud), but this simple function is getting an empty error and isn’t updating the label.
import { Client, Users } from 'node-appwrite';
export default async ({ req, res, log, error }) => {
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY);
const str = req.queryString;
const user_id = str.split('=')[1];
if (!user_id) {
error('User ID not provided');
return res.send('User ID is required', 400); // Bad Request
} else {
log(user_id);
}
const users = new Users(client);
// Update the user's labels
try {
const response = await users.updateLabels(user_id, ['subscriber']);
log(response);
return res.send('User labels updated successfully');
} catch (err) {
error(err);
return res.send('Failed to update user labels', 500); // Internal Server Error
}
};
version of node-appwrite?
also how are you sending the userId? as a json content, plain text?
Well, I use cloud version of the Appwrite that you got on the Starter tier. Functions are running in Node-18.0 Runtime. I've just clone starter function template, here's package.json:
{
"name": "starter-template",
"version": "1.0.0",
"description": "",
"main": "src/main.js",
"type": "module",
"scripts": {
"format": "prettier --write ."
},
"dependencies": {
"node-appwrite": "^9.0.0"
},
"devDependencies": {
"prettier": "^3.0.0"
}
}
userID is sending throw params from iOS client:
let execution = try await functions.createExecution(
functionId: "6527d2ed7f74ea014de7",
path: "/v1/params?userID=\(userID)",
method: "GET"
)
I've checked this id in the log and it is okay, issue with calling user API.
Oh, I see... current version of the node-appwrite is 11.0 already
Updated dependencies and the function completed successfully. It seems the templates need a small tune-up. Thanks @darShan !
[SOLVED]
[SOLVED] The function users.updateLabels is returning an empty error.
btw, you're seeing {} because you're doing error(err). You should make sure to pass a string there
Oh, right! Silly oversight from a Swift sailor in JavaScript seas ) Switch to log(err.message);
Btw, with node-appwrite": "^9.0.0" it returns users.updateLabels is not a function Start working properly from 10.0.0
afaik, 9.0.0 was built against 1.3x which didn't have the labels support. Labels were added in 1.4x.
Recommended threads
- 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...
- Python TablesDB Rework
Hi, i starting to rework some older functions to TablesDB list_rows Method. I used list_documents with a resultset with worked fine. Now i tried to get all rows...
- HUGE OUTRAGE IN APPWRITE, I CANNOT ACCES...
I have 2k users trying to access, sending me messages. What am I supposed to do? Please solve this asap.