
i dont get any response. There is also not log inputs. The server goes to 500 error
How I can use the res.json and console.log inside Promise.all?

is this an Appwrite Function? Is this all the code?

Function

I create now a fresh function with follwoing code: module.exports = async function (req, res) { const promise1 = Promise.resolve(3); const promise2 = 42; const promise3 = new Promise((resolve, reject) => { setTimeout(resolve, 100, 'foo'); });
Promise.all([promise1, promise2, promise3]).then((values) => { console.log('test') res.json({values}); }); };

res.json is working, but console.log not

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

can you try adding await
before Promise.all()
?

module.exports = async function (req, res) {
const promise1 = Promise.resolve(3);
const promise2 = 42;
const promise3 = new Promise((resolve, reject) => {
setTimeout(resolve, 100, 'foo');
});
Promise.all([promise1, promise2, promise3]).then((values) => {
console.log('test')
res.json({values});
});
};

testing

module.exports = async function (req, res) {
const promise1 = Promise.resolve(3);
const promise2 = 42;
const promise3 = new Promise((resolve, reject) => {
setTimeout(resolve, 100, 'foo');
});
await Promise.all([promise1, promise2, promise3]).then((values) => {
console.log('test')
res.json({values});
});
};
that helps. Thanks!

[SOLVED] Promise.all not responding res.json(), console.log not working
Recommended threads
- ENV vars not updating
When i do `nano .env` it shows `_APP_DOMAIN_TARGET=` as set to my domain, but when i do `docker compose exec appwrite vars` it shows `_APP_DOMAIN_TARGET=` as ...
- Index with the requested key already exi...
I'm using appwrite cli to create DB and I'm getting index_already_exists Is there a way to undestand the index name and maybe to skip if it's already exits?
- Issue - Migration From Cloud > Self Host...
Hi team, I’m trying to migrate a few of my Appwrite projects from the cloud to a self-hosted instance. These projects are currently in “archive mode” due to th...
