This week I spent a fair amount of time working through using fetch() and get fun API data was an interesting challenge. From an app design perspective, it has opened a new series of data to pull and combine for future and current smaller learning projects that will (hopefully) pan out into some fun interactive apps.
However, as with all new and exciting topics, it included multiple new bugs to work through. One unexpected issue was that my API projects now do not have a real database, so I had to use CORS, a well-built proxy designed for API projects for people like me who are learning (cors-anywhere.herokuapp.com). It now requires you to request permission each day to use it as a temp proxy server. So, for building an app that requires a database to “talk with” for public consumption beyond a learning exercise would require an actual database build… Which is coming soon! Stay tuned for my soon adventures in MySQL.
Why use something like the load event? What are some disadvantages, alternatives, and when to use them?
One well discussed disadvantage is that load events run instantly, so functions can run before data is retrieved from a database or the backend of the app or website. So, those that those functions may not be able to perform, so in those cases asynchronous functions would be a good choice.
Readystatechange and DOMContenetLoaded are alternatives to the load event. They are initiated when the DOM and its elements are ready to use, but before external resources are fully loaded.
You would use these when you do not need everything to load before running functions.
Here is a great video tutorial:
What is AJAX?
AJAX apps can use XML to transfer data, but can also transfer data as plain text or JSON text.
AJAX lets web pages to be updated asynchronously by exchanging data with a web server behind the scenes. This makes it possible to update parts of a web page, without reloading the entire web page.
What are the advantages and disadvantages of using Ajax?
AJAX allows webpages to update serially by exchanging a small amount of data with the server. This way it is possible to update parts of a webpage, without reloading the whole page.
Asynchronous data retrieval can be done by using XmlHttpRequest, so requests are handled effectively and this can improve the performance.
The webpage can be hard to debug, and it can increase the code size of your webpage.
How does JSONP work? (aka how it is not really Ajax)…
JSONP means JSON with Padding. It requests files using the script tag instead of the XMLHttpRequest object.
Ajax is using XMLHTTPRequest to request any kind of resource, but cross-domain feature depends on browser implement.
Reference Resource for expanded explanations: https://stackoverflow.com/questions/10289789/i-dont-get-how-jsonp-is-any-different-from-ajax
What does it mean when we talk about time complexity of an algorithm?
Time complexity refers to how many actions it takes to iterate through an array to find a specific element or handle and return a solution. If you have to iterate over an array of five items once, then your time complexity would be 1(n). If you have to re-iterate over an array (e.g., bubble sorting), then it would have a higher time complexity.
There are sometimes where a higher time complexity is necessary because other factors may need to be taken into account (e.g., memory)
Additional resources on this topic:
What are the three laws of algorithm recursion?
1) Must call itself recursively.
2) Must have a base case. Base cases are what let the algorithm stop recursing (so a stopping point otherwise you end up in an infinite loop- not cool!)
3) Must change its state and move towards the base case. The data changes until it meets the conditional of the base case. Essentially, the data is being manipulated in steps or increments towards the final solution.
How do I see myself growing as a web developer?
Did my first hello world in December, so growing a lot as far as skills, but also in my mindset that “failure” is actually a learning process, and debugging is not “de-failure” or trying to make up for a shortcoming, it is just part of the process. However, during some debugging periods, especially this weekend while I was sick, it can be difficult to keep a growth mindset at the forefront.
I know that I will be a good developer, because even after hitting some rougher debugging or coding patches, I keep coming back and keep learning. There is a very steep and intimidating learning curve, but being reassured that imposter syndrome is persistent even among senior developers helps, we all have the same struggles, because while I am still at the beginning of my coding journey, everyone has to start with the same “Hello World”.
If anyone needs some quick motivational videos, these are helpful. Also, very easy to listen to in the background when you are busy attempting “real life” when not coding to feel motivated again after some debugging time.
I hope this article helps anyone who needed some coding review, is dealing with API call debugging, or is curious about AJAX and what the heck it means (all the cool kids on StackOverflow seem to talk about it plenty)!
Your friend in code,