Application Program Interface (API) is a service that provides raw data for the public. We reviewed how we can create our own APIs so that we can use them for CRUD functionality in apps, which was a pretty fun scenario to take a look at.
In class, we played around with the following code to make API requests – and I thought it was a pretty good chunk of code that I could use for future reference when it comes to API-related projects:
var url = "https://api.wunderground.com/api/api_key/geolookup/conditions/q/va/midlothian.json"
// $.ajax takes an object as an argument with at least three key-value pairs...
// (1) The URL endpoint for the JSON object.
// (2) Type of HTTP request.
// (3) Datatype. Usually JSON.
console.log("Ajax request success!")
console.log("Ajax request fails!")
console.log("This always happens regardless of successful ajax request or not.")