Drupak Drupal Career Development Program
Working with APIs
This lecture, part of the DDCDP series, provides a comprehensive introduction to using the JavaScript fetch method to retrieve data from public APIs.
Key Concepts Covered:
- API Fundamentals: The instructor explains that APIs (Application Programming Interfaces) allow developers to programmatically access data from external servers, using the Metropolitan Museum of Art API as a practical example.
- HTTP Requests & URLs: The session breaks down the structure of a URL, distinguishing between the base URL, the path/endpoint, and query parameters (e.g.,
?search=cricket), which are used to send additional filtering instructions to a server. - The Fetch Method: The core of the lesson focuses on using
fetchto request data. The instructor demonstrates howfetchreturns a promise, necessitating the use ofasync/await(or.thenchains) to handle the response. - Data Handling:
- The raw response is a stream, which must be converted to JSON using the
.json()method. - Techniques for mapping through arrays of objects and using template literals to dynamically generate HTML string content are shown.
- The raw response is a stream, which must be converted to JSON using the
- Practical Application: The instructor builds a small interactive interface where a user can search for specific museum objects by ID. This includes:
- Implementing an event listener to handle form submissions.
- Using
e.preventDefault()to prevent the page from reloading upon search. - Updating the DOM via
innerHTMLto display the retrieved data.
The lecture concludes with a reminder that fetch is a fundamental tool for modern web development, with a brief mention of further HTTP methods to be explored in future lessons focused on PHP and Symphony.
Course Content
01
HTML, CSS And Tailwind CSS
02
JavaScript: Basic to Advanced
04
Advanced PHP Development
06
Drupal Development Masterclass
WHY CHOOSE US AS YOUR DRUPAL PARTNER?
We combine strong technical skills, business insight and hands-on Drupal AI experience in every project. With over 100 projects delivered since 2012, an Acquia-certified team and clear, honest communication, we turn complex technology into a real advantage for your business.