Library to return Image URL, Title and Description of a link for generation of preview of the link
#### Description
To show preview of a link, we need to know four things: the link itself, image URL, title and description of the link, the module is here to fulfill the need.
#### Examples
const { linkPreview } = require(\link-preview-node\);
linkPreview(\npmjs.com\)
.then(resp => {
console.log(resp);
_/\ { image: 'https://static.npmjs.com/338e4905a2684ca96e08c7780fc68412.png',
title: 'npm | build amazing things',
description: '',
link: 'http://npmjs.com' } \/_
// Note that '' is used when value of any detail of the link is not available
}).catch(catchErr => {
console.log(catchErr);
});
// In case you are comfortable with callbacks
const { linkPreviewCallback } = require(\link-preview-node\);
linkPreviewCallback(\npmjs.com\, (err, resp) => {
console.log(err ? err : resp);
});
// An error is returned in first argument of callback and catch block of promise when any invalid URL is supplied to the functions
linkPreview(\fdsafsgd.com\)
.then(ans => {
console.log(ans);
}).catch(catchErr => {
console.log(catchErr);
_/\ { Error: getaddrinfo ENOTFOUND fdsafsgd.com fdsafsgd.com:80
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'fdsafsgd.com',
host: 'fdsafsgd.com',
port: 80 } \/_
});
#### Reference
I would like to thank Rahul Taneja (
#### Report An Issue
If you find any issue in the module, you can report it at