+ 2

TypeError: req.next is not a function

Trying to practice Mongoose delete document by creating a delete page, which shows all todo-items. Here is my current app.get("/delete") https://code.sololearn.com/W41lckb7hQL2/?ref=app I don't know how to get all documents from all collections, so stupidly using for loop, but then can't res.render in find callback like app.get("/list") Got titled error... If commented out res.render and keep console.log, all documents are loaded into fulltodolist successfully.

12th Feb 2020, 8:42 AM
Gordon
Gordon - avatar
5 Antworten
+ 2
yeah, chaining then within variable length of promise is impossible. you can use async/await ( https://code.sololearn.com/W6ETN0lznWvb/?ref=app [i havent tested it] ) to replace then. exec() is used to return a Promise, so we can use async and await. kinda like this https://code.sololearn.com/WUutQ8OC3xhy/?ref=app
12th Feb 2020, 9:37 AM
Taste
Taste - avatar
0
i'm not fully understand, so you want to get all the data with name listed in todoListNames ?
12th Feb 2020, 9:05 AM
Taste
Taste - avatar
0
Yes todoListNames are the Collection names. I want to get all Document from all Collection. Which I already did. But how to pass them into the view engine? where should i res.render()? for single page, i do it like this: https://code.sololearn.com/WVe18BrqW0Bq/?ref=app put render in callback of find
12th Feb 2020, 9:26 AM
Gordon
Gordon - avatar
0
I see. Let me try tomorrow ~ Thanks~
12th Feb 2020, 10:00 AM
Gordon
Gordon - avatar
0
Taste at last, i solved with a for loop 😅 https://code.sololearn.com/W3uH2cQK7l48/?ref=app
13th Feb 2020, 3:46 AM
Gordon
Gordon - avatar