Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strapi v.3.6.5 - draft content not found #33

Open
thomaslkp123 opened this issue Mar 15, 2022 · 1 comment
Open

Strapi v.3.6.5 - draft content not found #33

thomaslkp123 opened this issue Mar 15, 2022 · 1 comment

Comments

@thomaslkp123
Copy link

Hi - I'm from a backend development background - so this issue is possibly due to lacking javascript knowledge.

Having installed the preview plugin - this works for cloning, and getting published content - via the preview API using a url like this:
/preview-content/custom-pages/2

However - for draft content - we get a 404 and the message: "Preview not found for given content type and Id".

Trying to debug the plugin - I can see that that line 131 in preview.js is returning null:
image

However I am unable to identify why this is.

Any help much appreciated!

@thomaslkp123
Copy link
Author

thomaslkp123 commented Mar 15, 2022

hi - resolved this by creating a custom controller endpoint - and then in the \node_modules\strapi\lib\core-api\service\index.js - I added method:

const getFetchParamsPreview = (params = {}) => {
 return {
   _publicationState: DP_PUB_STATE_PREVIEW,
   ...params,
   _limit: getLimitParam(params),
 };
};

And in \node_modules\strapi\lib\core-api\service\collection-type.js

findOnePreview(params, populate) {
      return strapi.entityService.findOne(
        { params: getFetchParamsPreview(params), populate },
        { model: modelName }
      );
    },    

This can probably be done in a better way ... but us this something that is missing in v3.6.5 in order for the preview plugin to work - ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant