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
- Appwrite Team we love using your service...
Custom domain many people are complaining and asking for answers from you guys it wouldn't take you a day to fix it why naa 🤔
- Bug Report CLI
So I wanted to generate types for the project using "appwrite types types". Expected outcome- generate ts type with the types. Got outcome- appwrite types...
- How Can I Create landing page in appwrit...
I created function called invoice URL https://app.getrestt.com/v1/functions/invoice/executions?id=test-76f948fe83c43422561fe096c0674a1bd3ff0702cdfcf2444293ab31...