소스 검색

use Promise.all

itizawa 5 년 전
부모
커밋
26335980ff
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      src/server/routes/apiv3/users.js

+ 4 - 3
src/server/routes/apiv3/users.js

@@ -601,10 +601,11 @@ module.exports = (crowi) => {
     const { id } = req.body;
 
     try {
-      const newPassword = await User.resetPasswordByRandomString(id);
-      const user = await User.findById(id);
+      const [newPassword, user] = await Promise.all([
+        await User.resetPasswordByRandomString(id),
+        await User.findById(id)]);
 
-      return res.apiv3({ user, newPassword });
+      return res.apiv3({ newPassword, user });
     }
     catch (err) {
       logger.error('Error', err);