Fetching Api using vanilla JavaScript vs jQuery

JavaScript:

	fetch('https://api.magicthegathering.io/v1/cards')
		.then(result => result.json())
		.then((res) => { createCard(res); })
		.catch(err => console.log(err))

	var myCards = document.getElementById('cards');

	function createCard(result) {
		var myCard = result['cards'];

		//some output can go here
		
		}
	}

jQuery:

	$.getJSON('https://api.spacexdata.com/v2/launches/next', function(data) {
		var launch_date_utc = data['launch_date_utc'];
		$('#next-launch').html(launch_date_utc);
	});

 

Leave a Reply

Your email address will not be published. Required fields are marked *