Hello, I'm currently rewriting my Cloudfunctions to the new syntax. I have one problem with error handling in a promise.
Old:
module.exports = async function (req, res) {
// some code
promise.then(
function (response) {
console.log(response);
},
function (error) {
console.log(error);
},
);
//some code
};
New:
export default async ({ req, res, log, error }) => {
// some code
promise.then(
function (response) {
log(response);
},
function (error) {
error(error);
},
);
//some code
};
In the New version I get the Error " error is declared but its value is never read." for the deconstructured context function. I think this is more like a general JavaScript problem, but can you help me out?
Are you using TS?
No
Please verify that if we have the same configuration
{
"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"
}
}
.prettierrc.json
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
Yes, I can confirm that it is the same configuration.
you're redeclaring the error
variable which can cause problems.
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...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...