func loadBy(_ req: Request) throws -> Future<[News]> {
let parentId = try req.parameters.next(String.self)
let parent = try self.findParentBy(req, parentId: parentId)
var childNews: [News] = []
let qq = parent.map(to: [News].self) { parentNews in
for chilId in parentNews!.childIds {
let ch = News.query(on: req).filter(\News.newsId == chilId).first().map(to: News?.self) { child in
if let child = child {
childNews.append(child)
}
return child
}
}
return childNews
}
return qq.flatMap(to: [News].self) { childNews in
return childNews.map { news in
Future.map(on: req) { news }
}.flatten(on: req)
}
}
在获得值之前返回
我想等到获得所需的值后再返回它们
答案 0 :(得分:1)
谢谢。与
一起使用async OpenPortal() {
const { email, password } = this;
try {
const res = await this.afAuth.auth.signInWithEmailAndPassword(
email + '@smartpark.com',
password
);
return this.OpenPortal.updateUserData(res.user);
this.router.navigate(['admin-portal']);
} catch (err) {
console.dir(err);
if (err.code === 'auth/user-not-found') {
console.log('User not Found');
}
}
}