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 + Cloudflare domain
So i have a domain with cloudflare, however i'm only given a new NS to change the domain to. im not 100% sure how i would do this and dthe docs aren't really ta...
- How to model user data and relationships...
I wonder how to model something like this: A user can create any amount of events. Each event belongs to one user. What I have done so far: Created a new tabl...
- Site SSR TanStack
Hey, I’m deploying a React + TanStack app on Appwrite Hosting. Can Appwrite Sites/SSR use Bun for runtime/build, or is it Node-only? I’m using Bun locally and w...