JS fetch request

PHOTO EMBED

Tue Oct 01 2024 12:17:19 GMT+0000 (Coordinated Universal Time)

Saved by @kanatov

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);
	}
}
content_copyCOPY