Hey! ๐Ÿ‘‹๐Ÿผ

API Calls

Redi School Munich - Spring 2021

APIs

Recap

  • API stands for Application Programming Interface.
  • Something that sends information back and forth between a website or app and a user

Example: Message delivery from your mom by one of your kids

Browser APIs

  • All browsers have a set of built-in Web APIs
  • Support complex operations
  • Help accessing data

More on built-in Web APIs

Demo!

Access external APIs - Fetch

  • Provides JavaScript interface for accessing and manipulating parts requests & responses
  • Replaces XMLHttpRequest
  • Wonโ€™t reject on HTTP error status (404 or 500)
                          
                              fetch('http://some-domain.com/movies.json')
                                .then(response => console.log(response.json()));
                        
                        

More on fetch

{JSON} Placeholder

Check it out!

Demo!

In-class excercise ๐Ÿ’ป

In groups, implement a GET request to fetch an element via the 'id' & a POST request to create an element

  • Group 1: /comments
  • Group 2: /albums
  • Group 3: /photos
  • Group 4: /todos
  • Group 5: /users

Hint: the value 'id' is generated by the API on POST & Use the Guide!

Homework!

Work on your project an include an API call

Think about questions for the next session

Questions or Feedback?