---
# System prepended metadata

title: '2009-GHP-NY Cookie Jar: Express, Handling Asynchronous Code'

---

# 2009-GHP-NY Cookie Jar: Express, Handling Asynchronous Code


## Lecture: Intro to Express Part 1

### What is the difference between http and https? Google said http is less secure, why is it less secure? and is it going to impact how we code in the back end?
***Answer:***
This will ***not*** impact how we build our routes in the backend using Express.js.
The "s" in "HTTPS" stands for "secure," and as you can suspect, it is a more _secure_ protocol than HTTP. HTTPS messages are encrypted and use TLS (Transport Layer Security) or SSL (Secure Sockets Layer). HTTP messages are ***not*** encrypted and use TCP (Transmission Control Protocol).
I will leave it at that for now since the topic of Web Security will be covered during Async Week (the week between Junior and Senior phases).

- ***Extra Resources:***
  - [Cloudflare: Why is HTTP not secure? | HTTP vs. HTTPS](https://www.cloudflare.com/learning/ssl/why-is-http-not-secure/)
  - [HTTP vs HTTPS: The Difference And Everything You Need To Know](https://seopressor.com/blog/http-vs-https/)

## Lecture: Intro to Express Part 2

None asked.


## Lecture: Handling Asynchronous Code

### Can we please go over the bonus for `findPasword()` with the `try`/`catch` block? Also, what's the difference between a `.then`/`.catch` and a `try`/`catch`?

***Answer:***
Regarding `findPassword()`, this is a question for either Morning Review (bottom of Exit Ticket form) or an office hour session!
`try`/`catch` statements are ***typically*** used in conjunction with asynchronous operations that use `async`/`await` syntax. (Note: We used `try`/`catch` statements in our `gems.js` example during the demo, which did ***not*** have any asynchronous code.)
`.then`/`.catch` are used when Promise chaining: `.then` callback functions run when the function it is chaining/dotting off of was successful; `.catch` callback functions run when ***any*** upstream operation in the Promise chain throws an error (i.e. it **bubbles down** to the `.catch`).

- ***Extra Resources:***
  - [MDN: Promise.prototype.then()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then)
  - [MDN: Promise.prototype.catch()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch)
  - [MDN: try...catch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch)
  - [JavaScript.info: Error handling, "try..catch"](https://javascript.info/try-catch)
  - [JavaScript.info: Error handling with promises](https://javascript.info/promise-error-handling)