Quiz

  1. I think I'm just still a little confused on how all these are related to each other.

    Who could blame you? We've already seen one summary; let's try another:

    • JS running in the browser can initiate requests.
    • GET and POST are just like usual, but we also have PUT and DELETE.
    • The back end can respond with JSON instead of a web page
    • JS running in the browser can receive the response and (optionally) update the page.
    • Often GET/POST/PUT/DELETE are used in a particular way called a REST API.
  2. Do POST and GET in ajax work the same way as methods in HTML forms?

    Yes. Well, the request is the same, but the response is different

  3. are there any examples from past projects that used ajax?

    A lot of people end up creating "like" buttons; that's a good use of Ajax. Sometimes they even do comments and such.

  4. Can you talk more about APIs work?

    There are two answers here. One general and one more specific.

    In general, an API (application program interface) is how one program talks to another.

    For example, we can talk about the bcrypt API, which consists of just two functions: gensalt and hashpw. Or the Flask API, which is much more complicated.

    In the context of this reading, an API is a set of endpoints and HTTP methods that allow a front-end (usually a browser, but might be another program) to talk to a back-end (a web server).

  5. How do we switch between Javascript and HTML code? Can we go over the REST API example again?

    The HTML <script> allows you to embed JS code in an HTML page, or to load JS code from an external file.

    I'm happy to go over the REST API

  6. Can you please go over the person app providing the rest api code?

    Sure. Here's the link to the people app