Matthias MerkOriginal post
Rank 1: Thread
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?
Summary
The user is facing an issue with error handling in a cloud function. They are rewriting their code to a new syntax and have encountered a problem. The error message they receive is "error is declared but its value is never read." They would like assistance with this issue.
Solution: The error is occurring because the user is redeclaring the `error` variable in the new version. To fix this, they should update the code to use a different variable name for error handling, such as `err`.