zahmis 5 anni fa
parent
commit
e52a87af93
1 ha cambiato i file con 4 aggiunte e 5 eliminazioni
  1. 4 5
      src/server/routes/apiv3/attachment.js

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

@@ -39,10 +39,12 @@ 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;
-
       // check whether accessible
       const isAccessible = await Page.isAccessiblePageByViewer(pageId, req.user);
       if (!isAccessible) {
@@ -53,10 +55,7 @@ module.exports = (crowi) => {
       const attachments = await Attachment.find({ page: pageId });
       const pagination = await Attachment.paginate(
         { page: pageId },
-        {
-          offset: +req.query.offset || 0,
-          limit: +req.query.limit || 30,
-        },
+        queryOptions,
       );
 
       const result = { attachments, pagination };