async function fetchGET(url: string): Promise<any> { try { const response = await fetch(url); if (!response.ok) { throw new Error( `Unable to Fetch Data, Please check URL or Network connectivity!!` ); } const data = await response.json(); return data.results[0]; } catch (error) { console.error('Some Error Occured:', error); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter