OP-Engineering/link-preview-js

A way to not throw an error if there's no URL in the text

eltel opened this issue · 2 comments

eltel commented

Is your feature request related to a problem? Please describe.
So, I'm working on a forum/social media type platform where people will enter all sorts of text in their posts, with and without URLs - and, basically, I'd like a way for this not to throw an error - I've tried multiple workarounds, with no luck.

Describe the solution you'd like
For users to be able to enter text with or without URLs in the same field and for the app not to throw an error if there is no URL

Describe alternatives you've considered
Multiple if/try catch combos to no avail

Additional context
This is the error which breaks the app:
error - unhandledRejection: Error: link-preview-js did not receive a valid a url or text
If you have any ideas of any workarounds or if I'm missing something blatantly obvious I'd love some advice (not exactly a noob but far from senior level)

Many thanks for your great work on this!

you just need to .catch or try..catch the call to getting the link preview

eltel commented