parcel-plugin-ogimage
parcel-plugin-ogimage copied to clipboard
UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of null
When I try to transform the following tags:
<meta property="og:title" content="V!RTL" />
<meta property="og:image" content="assets/logo.svg" />
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="v1rtl.site" />
I get this error:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of null
at getMetaTag (/home/v1rtl/Desktop/Coding/v1rtl.site/node_modules/parcel-plugin-ogimage/index.js:11:25)
at Bundler.<anonymous> (/home/v1rtl/Desktop/Coding/v1rtl.site/node_modules/parcel-plugin-ogimage/index.js:35:20)
at Bundler.emit (events.js:203:13)
at Bundler.bundle (/home/v1rtl/Desktop/Coding/v1rtl.site/node_modules/parcel-bundler/src/Bundler.js:361:12)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
(node:15421) 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(). (rejection id: 1)
(node:15421) [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.
Assets content:
➜ tree assets -L 1
assets
├── animation
├── art_bg.webp
├── background.webp
├── blog.webp
├── desktop.webp
├── icons
├── logo.svg
├── marker.webp
├── robots.webp
└── web_bg.webp
Thanks for submitting an issue.
From the readme:
This plugin uses the value of the
og:url
meta tag to convertog:image
to an absolute URL.
You don't have an og:url
meta tag so the plugin is throwing an error.
It would help if we checked for the tags and threw a more useful error explaining the issue. PR welcome.
Thank you for explaining the issue, yes, I'll make a PR for more friendly message