wordprismic icon indicating copy to clipboard operation
wordprismic copied to clipboard

Error when categoriesType not present

Open hades200082 opened this issue 3 years ago • 0 comments

If you remove the categoriesType property from the config file completely (it is marked as optional after all) then the following error happens:

Config file

module.exports = {
  wordpress: {
    url: 'https://www.parcelhub.co.uk'
  },
  prismic: {
    repo: 'parcelhubltd',
    locale: 'en-gb'
  },
  optimizeMediaRequests: false,
  schema: async function(post, html) {
    return {
      type: 'post',
      uid: post.slug,
      title: html.decode(post.title.rendered),
      content: await html.parse(post.content.rendered)
    };
  }
};

CLI output

> npx wordprismic -c .\wp-prismic-config.js
Downloading content
Fetching users...
Fetching posts...
Fetching page 2 of posts...
Fetching page 3 of posts...
(node:43264) UnhandledPromiseRejectionWarning: Error: Unable to encode undefined of type undefined
    at j (C:\Users\lee20\AppData\Roaming\npm-cache\_npx\43264\node_modules\wordprismic\node_modules\prismic-javascript\dist\prismic-javascript.min.js:1:11288)
    at Object.at (C:\Users\lee20\AppData\Roaming\npm-cache\_npx\43264\node_modules\wordprismic\node_modules\prismic-javascript\dist\prismic-javascript.min.js:1:12560)
    at mapCategories (C:\Users\lee20\AppData\Roaming\npm-cache\_npx\43264\node_modules\wordprismic\lib\utils.js:90:26)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async C:\Users\lee20\AppData\Roaming\npm-cache\_npx\43264\node_modules\wordprismic\bin\index.js:21:14
(Use `node --trace-warnings ...` to show where the warning was created)
(node:43264) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:43264) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

hades200082 avatar May 03 '21 10:05 hades200082