shahednasser / cross-post

Cross Post a blog to multiple websites
https://www.npmjs.com/package/cross-post-blog
MIT License
122 stars 16 forks source link

Fixed the bug `UnhandledPromiseRejection`. #41

Closed EthanRodrigo closed 1 year ago

EthanRodrigo commented 1 year ago

cross-post recently had a bug with Hashnode as it's updated. Here it is.


  ◜ Processing URL...node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: 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(). The promise rejected with the reason "#<Object>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v19.3.0```

This occurs because the tool can't find the image for the Hashnode as it's old way of storing the images has changed. Therefore I added a new function named `getImageForHashnode()` which returns the image from Hashnode. The cross-post tool still can't find the first image of the articles that are being controlled by or written on Hashnode, but not hosted there. I wish this pull request will be helpful for the tool and further debugging of the other bugs. 

Happy Coding!