zahmis 5 tahun lalu
induk
melakukan
b47ccf8d74

+ 5 - 2
src/client/js/components/PageAttachment.jsx

@@ -32,8 +32,11 @@ class PageAttachment extends React.Component {
       return;
     }
 
-    const res = await this.props.appContainer.apiv3Get('/attachment/list', { pageId });
-    const attachments = res.data.result.attachments;
+    const limit = 10;
+    // offset値は、dummy data この後のタスクで実装
+    const offset = 0;
+    const res = await this.props.appContainer.apiv3Get('/attachment/list', { pageId, limit, offset });
+    const attachments = res.data.paginateResult.docs;
     const inUse = {};
 
     for (const attachment of attachments) {

+ 2 - 5
src/server/routes/apiv3/attachment.js

@@ -52,15 +52,12 @@ module.exports = (crowi) => {
         return res.apiv3Err(new ErrorV3(msg, 'attachment-list-failed'), 403);
       }
 
-      const attachments = await Attachment.find({ page: pageId });
-      const pagination = await Attachment.paginate(
+      const paginateResult = await Attachment.paginate(
         { page: pageId },
         queryOptions,
       );
 
-      const result = { attachments, pagination };
-
-      return res.apiv3({ result });
+      return res.apiv3({ paginateResult });
 
     }
     catch (err) {