Closed shubhammantri1 closed 10 months ago
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');
});
Yes @rahulmah5.
PR it! :)
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.
https://github.com/UdaraJay/Pile/blob/0b37f8c695b45a38423764c88f58d82bf3268f2c/src/main/utils/linkPreview.js#L27