I am new to typescript and angular and observables. My question is I have this method that takes a URL and returns the favicon of that URL. How can I use observables instead of promise
getFavIcon(url: string): Promise<any> {
return new Promise((resolve, reject) => {
const hostname = this.getDomain(url);
const src = 'http://' + hostname + '/favicon.ico';
const image = new Image();
image.onerror = () => {
reject({ hasFavourite: false });
};
image.onload = () => {
resolve({ hasFavourite: true, imageURL: src});
};
image.src = src;
});
}