#100Devs - Another API Review

Class 28 of our Free Web Dev Bootcamp for folx affected by the pandemic. Join live T/Th 6:30pm ET leonnoel.com/twitch and ask questions here: leonnoel.com/discord

Skip to first slide
Slide 1 of 51

 

Javascript - Another API Review 

Leon Noel

#100Devs

And that's why you remind me
That I can never be lost in the sauce, I'm a boss
And everything was a lesson, from that loss, I gained it all


Slide 2 of 51

Agenda


Slide 3 of 51

Questions

About last class or life


Slide 4 of 51

Checking In

Like and Retweet the Tweet

!checkin


Slide 5 of 51

No Networking Until May


Slide 6 of 51

Client Deadline: May 3rd


Slide 7 of 51

Client Alternatives


Slide 8 of 51

Grassroots Volunteer*


Slide 9 of 51

Free Software / Open Source

https://www.firsttimersonly.com/


Slide 10 of 51

Codewars !Clan

Clan: #100Devs - leonnoel.com/twitch


Slide 11 of 51

Submitting Work

Please submit your API work

Submit URLs here: https://forms.gle/mSR6TGf7F6iN54Wy5

 


Slide 12 of 51

"Break"

No "Class" Next Week


Slide 13 of 51

Slide 14 of 51

Work Together Nights

Tuesday / Thursday


Slide 15 of 51

Homework

Do: Catch Up

Do: Intro JS Course

Do: Professional Checklist


Slide 16 of 51

GIT BOWL

Sunday April 24th


Slide 17 of 51

Programming


Slide 18 of 51

What is a program?

A program is a set of instructions that you write to tell a computer what to do


Slide 19 of 51

What is a programming?

Programming is the task of writing those instructions in a language that the computer can understand.


Slide 20 of 51

JAVASCRIPT


Slide 21 of 51

Loops

What are loops?


Slide 22 of 51

Loops


Slide 23 of 51

Loops - For

for (let i = 1; i < 5; i++) {
  console.log(i)
}

Slide 24 of 51

Arrays

What are arrays?


Slide 25 of 51

Toasters


Slide 26 of 51

Arrays


Slide 27 of 51

Declaring Arrays

let newArr = []

Literal Notation


Slide 28 of 51

Declaring Arrays

newArr = ['Zebra',true,21]

Arrays are populated with elements

Elements can be of any type


Slide 29 of 51

Array Indexing


Slide 30 of 51

Array Indexing

newArr = ['Zebra',,true,21]

console.log( newArr[0] )  //Zebra
console.log( newArr[1] )  //undefined
console.log( newArr[2] )  //true
console.log( newArr[3] )  //21

Elements can be accessed by their index numbers


Slide 31 of 51

Array Indexing

newArr = ['Zebra',,true,21]

newArr[1] = 'Bob'

console.log( newArr )  

// ['Zebra','Bob',true,21]

Elements can be updated by using the index at that position


Slide 32 of 51

Array Length

console.log( newArr.length ) //4

How do you determine how many elements are in your array?


Slide 33 of 51

Array Iteration

let bestColors = ['green','blue','yellow','black']

bestColors.forEach((x,i)=> console.log(x))

Iterates through an array passing in the value and index of each element 


Slide 34 of 51

Objects

What are objects?


Slide 35 of 51

Objects


Slide 36 of 51

Think of a physical object

What are it's attributes and behaviors? 


Slide 37 of 51

Stopwatch Object

let stopwatch = {}

stopwatch.currentTime = 12

stopwatch.tellTime = function(time){
  console.log(`The current time is ${time}.`)
}

stopwatch.tellTime(stopwatch.currentTime)

Slide 38 of 51

APIs

What are APIs?


Slide 39 of 51

APIs


Slide 40 of 51

APIs


Slide 41 of 51

APIs

Fetch Fido, Fetch!

fetch("https://dog.ceo/api/breeds/image/random")
    .then(res => res.json()) // parse response as JSON
    .then(data => {
      console.log(data)
    })
    .catch(err => {
        console.log(`error ${err}`)
    });

API returns a JSON object that we can use within our apps


Slide 42 of 51

APIs

Stop trying to make Fetch happen!

fetch(url)
    .then(res => res.json()) // parse response as JSON
    .then(data => {
      console.log(data)
    })
    .catch(err => {
        console.log(`error ${err}`)
    });

Some APIs need Query Parameters to return the correct data

const url = 'https://www.thecocktaildb.com/api/json/v1/1/search.php?s=margarita'


Slide 43 of 51

Let's Code

Objects - DnD


Slide 44 of 51

Local Storage


Slide 45 of 51

Local Storage

Allows you to store data across browser sessions


Slide 46 of 51

Put Item Into Local Storage

localStorage.setItem('bestFriend', 'Bob')

Slide 47 of 51

Get Item Out Of Local Storage

localStorage.getItem('bestFriend', 'Bob')

Slide 48 of 51

Remove Item In Local Storage

localStorage.removeItem('bestFriend', 'Bob')

Slide 49 of 51

Remove All In Local Storage

localStorage.clear()

Slide 50 of 51

Let's Code

A Book Tracker


Slide 51 of 51

Homework

Do: Catch Up

Do: Intro JS Course

Do: Professional Checklist