HOMEWORK: Continue with your projects
PREP FOR NEXT SESSION: https://github.com/HackYourFuture-CPH/JavaScript/blob/main/javascript3/week2/preparation.md
Rules: JSON names require double quotes, no trailing commas
Data types: a string
, number
, object
, array
, boolean
, null
Parse (convert) string (JSON) into JavaScript object by using: JSON.parse
Convert object back to string by: JSON.stringify
Safety advice: Remember to always try
& catch
Resources & exercises
👶 Explain it like I’m 5
”You have a friend who knows a lot about cars. You don't know how they know, or where they get their info from, but you know if you ask them something like ‘what cars did Honda release in 2019?’ or ‘tell me the gas mileage of a Ford Focus’ that they will give you a good answer. They don’t care what you do with the answer, and you can do with the information whatever you like; for example, you could write it on a whiteboard that you have in your living room, and periodically update the info by checking in with them.”
— adapted from https://www.reddit.com/r/webdev/comments/en04ct/comment/fdtqdnj/?utm_source=share&utm_medium=web2x&context=3
Application Programming Interface
An API is an interface between computer programs
A REST API is one type of API that typically uses JSON
On the web, REST APIs are the most commonly used type of API
Resources & exercises
fetch is a built-in utility supported by all major browsers
It can be used to send requests to a REST API and retrieve the response data
It’s an async utility – returning a Promise, due to the nature of HTTP-requests
fetch has several options like
GET
, POST
, DELETE
...)Content-Type
or Accept
credentials: 'include'
Resources & exercises