This is the second part of a two-part series exploring the use of the Angular 6 HttpClient to make API calls against a Django back-end using Django Rest Framework. In the first part, we learned how to authenticate against Django using the Django Rest Framework JWT package. This post demonstrates how to set up the Django models and views for the micro-blogging app, as well as the Angular Service and templates.
Curious about how to make API calls with Angular 6 and the HttpClient service? This tutorial will show you some techniques for building a decoupled micro-blogging application using Angular 6 and the Django Rest Framework (DRF). Along the way, we will learn the following:
- How to set up the back end of the app using Django and the Django Rest Framework API
- Creating a simple Angular 6 single-page app which can query the API
- Authenticating users with JSON Web Tokens (JWT)
Ready? Let's get started!
With the release of Angular 6.0 in May 2018, the framework has been updated to depend on version 6.0 of the RxJS library. RxJS 6.0 has some breaking changes compared to RxJS 5.5 and older, specifically in the handling of some of the methods of the Observable class. This will affect the way Angular developers write API calls and handle other asynchronous processing in the future.
This post outlines some of the changes and how to update your API calls to the new syntax.
Note to readers, May 18, 2018: the code in this post is built for Angular 5.x. The same techniques will work with Angular 6 as long as you use the rxjs-compat Node package. To see how to upgrade this code for full, native RxJS compatibility, see this post.
I know that in my previous post, mocking API's in Golang, I said I would talk about testing, but I lied. To your face. I'm actually going to take a step backwards and talk a bit about the Golang environment configuration.
Software development in 2016 is a crazy complex process. Modern applications are increasingly distributed, regularly requiring access to an array of systems controlled by 3rd, 4th and 5th parties. So what happens when we are building the next killer-app-uber-disrupting-unicorn and the API that we NEED to access goes down?
Slam our Macbooks shut, whine about up-time and go home?
Consume our body weight in caffeine in preparation for the glorious return of the API?
Sit quietly and wait for morning to come?
Update, November 27, 2017: This post explains the Http service used in Angular 2. This is now deprecated in favor of the newer HttpClient released in Angular 4.3. This post will remain here as long as Angular 4.x is in long term support. If you are using Angular 5, consider upgrading to the newer HttpClient. You can find a tutorial for the HttpClient service in my post Angular 5: Making API calls with the HttpClient service.
Angular 2 provides a new pattern for running asynchronous requests, called Observables. Here, we will review a few of the concepts and eventually see how to run multiple concurrent HTTP requests, with the callbacks running only after all of them have completed.
Ken Burns America launched this week on the PBS.org website. In partnering with Kapow, Metal Toad took on the task of modifying and patching the NotreDAM Digital Asset Manager to meet the content repository and asset management goals of the project. From there, we created a lightweight client API to expose NotreDAM's data to the project's Django-based websites, built "NotreDAM Light", an asset browser for Django, integrataed Solr for search, and assisted with SEO and Django app development tasks.
The toad just finished a small project involving the Facebook API and by far the most confusing aspect of the project was the terminology regarding the many, many different API's and what each one actually does. I thought this merited a write-up and I hope you find it helpful.