Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging improvements #50

Closed
shubhammantri1 opened this issue Jan 2, 2024 · 3 comments
Closed

Logging improvements #50

shubhammantri1 opened this issue Jan 2, 2024 · 3 comments

Comments

@shubhammantri1
Copy link

Thrown error message should be 'Not an HTML/Text content'. It will help to debug the issue with more ease. Also, It'll be helpful if we print contentType to get more clarity.

throw new Error('Not an HTML content');

@rahulmah5
Copy link
Contributor

Would the below help?-

export const getLinkPreview = async (url) => {
  try {
    const response = await axios
      .get(url, {
        headers: {
          Accept: 'text/html',
        },
      })
      .then((response) => {
        const contentType = response.headers['content-type'];
        console.log(contentType);
        if (contentType && contentType.includes('text/html')) {
          return response;
        }
        throw new Error('Not an HTML/Text content');
      });

@shubhammantri1
Copy link
Author

Yes @rahulmah5.

@UdaraJay
Copy link
Owner

UdaraJay commented Jan 6, 2024

PR it! :)

rahulmah5 added a commit to rahulmah5/Pile that referenced this issue Jan 6, 2024
UdaraJay added a commit that referenced this issue Jan 6, 2024
* Logging improvements #50

* Update linkPreview.js

Signed-off-by: Udara Jay <UdaraJay@users.noreply.github.com>

---------

Signed-off-by: Udara Jay <UdaraJay@users.noreply.github.com>
Co-authored-by: Udara Jay <UdaraJay@users.noreply.github.com>
@UdaraJay UdaraJay closed this as completed Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants