jacktuck / unfurl

Metadata scraper with support for oEmbed, Twitter Cards and Open Graph Protocol for Node.js :zap:
MIT License
481 stars 52 forks source link

Seeing "Uncaught (in promise) TypeError: url_1.URL error" #111

Closed gvasudevgh closed 1 year ago

gvasudevgh commented 1 year ago

Seeing an issue while trying the package in my React, TypeScript environment. It can be reproduced at codesandbox.io - https://codesandbox.io/s/optimistic-liskov-36c96s?file=/App.js

In a nutshell I installed via npm i unfurl.js. Here's the code I'm testing. ` import { unfurl } from "unfurl.js"; import { useEffect } from "react";

function App() { const previewLink = "https://www.yahoo.com"; useEffect(() => { const getLinkMetaData = async () => { const result = await unfurl(previewLink); console.log(result.title); }; getLinkMetaData(); }, []); return <>hello world!</>; } export default App; `

I get the following error. index.ts:51 Uncaught (in promise) TypeError: url_1.URL is not a constructor at getPage (index.ts:51:17) at unfurl (index.ts:42:10) at getLinkMetaData (LinkPreview.tsx:13:34) at LinkPreview.tsx:16:9 at commitHookEffectListMount (react-dom.development.js:23150:26) at commitPassiveMountOnFiber (react-dom.development.js:24926:13) at commitPassiveMountEffects_complete (react-dom.development.js:24891:9) at commitPassiveMountEffects_begin (react-dom.development.js:24878:7) at commitPassiveMountEffects (react-dom.development.js:24866:3) at flushPassiveEffectsImpl (react-dom.development.js:27039:3)

Included screenshots below. "URL" shows undefined in the chrome inspector in the callback.

image

image

I've tried messing around with node versions based on the issue #92 . I think it's the wrong path. If it wasn't for the fact that I can reproduce it in codesandbox too (see link above), I wouldn't be logging the issue. Reaching out to see if anyone else has seen this or it's a legitimate issue.

Thanks for the time.

jacktuck commented 1 year ago

The library isn't expected to work client-side. Even if you could get it to work you would get CORS errors which render it unusable.

Similar to #57

gvasudevgh commented 1 year ago

doh. Missed the obvious. Appreciate the response.

jacktuck commented 1 year ago

No problem