Its an easy question. Ive this try/catch:
TypeScript
try {
const userResponse: Models.User<Models.Preferences> = await users.get(id);
const user = JSON.stringify(userResponse);
return res.send(user);
} catch (err) {
log('Appwrite getUser: Error getting user. id: ' + id);
return res.send(err);
}```
Since there is no res.status, what is the best way to send an error to the client? Just res.send it? This will not trigger the try/catch error handling on the client...
thanks π
TL;DR
To forward an error to the client without res.status in an Express application, developers can set the statusCode manually to a 4xx code. A common approach is to use the res.send method to send the error message to the client but keep in mind that this may not trigger the try/catch error handling on the client side.set statusCode to 4xx
Recommended threads
- Can't really use the S3 storage device
hi, I've linked my local MinIO Instance (it's just for testing, not for prod.) to my appwrite instance, when i'm uploading a file it's getting uploaded to the S...
- Next.js SSR Site Times Out on First Visi...
Hey everyone, I'm running a Next.js SSR site on a self-hosted Appwrite server (v1.9.0), and I've noticed a strange behavior that I'm hoping someone can help me...
- Appwrite migration stuck on pending
Migration an existing self hosted 1.9.0 to a new VPS tuning self hosted 1.9.0.. import data recognises the api url, project id and api and then when I create, i...