zahmis 5 سال پیش
والد
کامیت
41654bf017
1فایلهای تغییر یافته به همراه7 افزوده شده و 4 حذف شده
  1. 7 4
      src/server/routes/apiv3/attachment.js

+ 7 - 4
src/server/routes/apiv3/attachment.js

@@ -39,9 +39,6 @@ module.exports = (crowi) => {
    *              type: string
    */
   router.get('/list', accessTokenParser, loginRequired, async(req, res) => {
-    const offset = +req.query.offset || 0;
-    const limit = +req.query.limit || 30;
-    const queryOptions = { offset, limit };
 
     try {
       const pageId = req.query.pageId;
@@ -54,7 +51,13 @@ module.exports = (crowi) => {
       }
 
       const attachments = await Attachment.find({ page: pageId });
-      const pagination = await Attachment.paginate({ page: pageId }, { queryOptions });
+      const pagination = await Attachment.paginate(
+        { page: pageId },
+        {
+          offset: +req.query.offset || 0,
+          limit: +req.query.limit || 30,
+        },
+      );
 
       const result = { attachments, pagination };