laurengarcia / url-metadata

NPM module: Request a url and scrape the metadata from its HTML using Node.js or the browser.
https://www.npmjs.com/package/url-metadata
MIT License
166 stars 43 forks source link

Response Code 0 #65

Closed indrazm closed 8 months ago

indrazm commented 9 months ago

Hey, I have issue when using this.

I got this error. fetch error: Error: response code 0

Here is my code.

const handleOnScrapeMetadata = async (event: React.ChangeEvent<HTMLInputElement>) => {
    const url = event.target?.value;
    const options = {
      cache: 'no-cache',
      mode: 'no-cors',
      timeout: 10000,
      descriptionLength: 750,
      ensureSecureImageRequest: true,
      includeResponseBody: true,
    };

    console.log('fetching metadata for:', url);

    try {
      const metadata = await urlMetadata(url, options);
      console.log('fetched metadata:', metadata);
    } catch (err) {
      console.log('fetch error:', err);
    }
  };

Is there anything i am missing of ?

laurengarcia commented 9 months ago

status 0 usually means a CORS issue, maybe try changing "mode" to "cors".