I am having trouble creating a link preview in live chat on my website. I want the preview of a dropped URL to show in the chat window, which requires extracting meta-data from the element of the resource (in that URL) like:
<meta property="og:image" content="https://baomoi-static.zadn.vn/web/styles/img/facebook-thumb.png">
. In my Angular TypeScript project, I am using the head() method of HttpClient as shown below:
getMetaData(url: string) {
let headers = new HttpHeaders();
headers = headers.append('Access-Control-Allow-Headers', '*');
headers = headers.append('Access-Control-Allow-Methods', '*');
headers = headers.append('Access-Control-Allow-Origin', '*');
const options = {
headers: headers,
reportProgress: true,
responseType: 'json',
};
return this.http.head(url, <HttpOptions>options);
}
However, when I use this method of HttpClient, I encounter an error. Can someone assist me in resolving this issue or provide a solution for retrieving metadata from a specific URL? I am currently working on an Angular TypeScript project.