zahmis 5 лет назад
Родитель
Сommit
e676ec37b4

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

@@ -32,9 +32,9 @@ class PageAttachment extends React.Component {
       return;
     }
 
-    this.props.appContainer.apiGet('/attachments.list', { page_id: pageId })
+    this.props.appContainer.apiv3Get('/attachments/list', { pageId })
       .then((res) => {
-        const attachments = res.attachments;
+        const attachments = res.data.attachments;
         const inUse = {};
 
         for (const attachment of attachments) {

+ 5 - 3
src/server/routes/apiv3/attachment.js → src/server/routes/apiv3/attachments.js

@@ -1,6 +1,6 @@
 const loggerFactory = require('@alias/logger');
 
-const logger = loggerFactory('growi:routes:apiv3:attachment'); // eslint-disable-line no-unused-vars
+const logger = loggerFactory('growi:routes:apiv3:attachments'); // eslint-disable-line no-unused-vars
 
 const express = require('express');
 
@@ -23,7 +23,7 @@ module.exports = (crowi) => {
   /**
    * @swagger
    *
-   *    /attachment/list:
+   *    /attachments/list:
    *      get:
    *        tags: [Attachment]
    *        description: Get attachment list
@@ -41,7 +41,7 @@ module.exports = (crowi) => {
   router.get('/list', accessTokenParser, loginRequired, async(req, res) => {
 
     try {
-      const pageId = req.query.page;
+      const pageId = req.query.pageId;
 
       // check whether accessible
       const isAccessible = await Page.isAccessiblePageByViewer(pageId, req.user);
@@ -51,7 +51,9 @@ module.exports = (crowi) => {
       }
 
       const attachments = await Attachment.find({ page: pageId });
+
       return res.apiv3({ attachments });
+
     }
     catch (err) {
       logger.error('Attachment not found', err);

+ 1 - 1
src/server/routes/apiv3/index.js

@@ -44,7 +44,7 @@ module.exports = (crowi) => {
   router.use('/share-links', require('./share-links')(crowi));
 
   router.use('/bookmarks', require('./bookmarks')(crowi));
-  router.use('/attachment', require('./attachment')(crowi));
+  router.use('/attachments', require('./attachments')(crowi));
 
   return router;
 };