Fireship · @fireship
Angular HTTP Client Quick Start Tutorial
Uploaded October 9, 2017 · Length 9:56
Summary
This tutorial teaches how to use Angular's HTTP client to interact with RESTful APIs, including making GET, POST, and other requests, and handling errors.
- angular http client tutorial
- restful api tutorial
- angular http requests
- angular error handling
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
mastering the basics of angular's HTTP
- 0:02
module well open up the door to interact
- 0:04
with thousands of exciting web-based
- 0:06
api's by the end of this lesson you'll
- 0:08
have the basic tools you would need to
- 0:09
do things like request weather data
- 0:11
stock quotes nutrition facts as well as
- 0:13
interact with major platforms like
- 0:15
Facebook Twitter and Amazon Web Services
- 0:18
the one thing these products all have in
- 0:19
common is that they provide a restful
- 0:21
api that you can consume from your
- 0:23
angular app Before we jump into the code
- 0:25
let's quickly look at what a restful api
- 0:27
is and how communication works between
- 0:29
the client and the server so here we
- 0:32
have a client on the left and a server
- 0:34
on the right rest is simply a way for
- 0:36
these two parties to communicate in a
- 0:38
standardized way when the client makes a
- 0:40
request it's going to use a specific
- 0:42
verb or method to interact with the
- 0:44
server first we'll go ahead and make a
- 0:46
get request this tells the server that
- 0:48
we only want to retrieve data and we're
- 0:50
not going to modify it in any way the
- 0:52
server will respond with the status code
- 0:54
as well as the data that was requested
- 0:55
if it was a successful request it should
- 0:58
be a 200 level response but if the
- 1:00
request wasn't valid it should be a 400
- 1:02
or 500 level error response a 400
- 1:05
response generally means the client
- 1:07
screwed something up and a 500 level
- 1:09
response generally means there was an
- 1:11
error on the server itself if we send a
- 1:13
post request we're telling the server
- 1:15
that we intend to create new data when
- 1:17
you send a post request you also send
- 1:19
that data payload with it which is the
- 1:21
data you intend to save on the server
- 1:23
after the server successfully saves it
- 1:25
it should respond with a 201 success
- 1:27
message this time saying that the
- 1:29
resource was created in addition to
- 1:31
getting post you also have other verbs
- 1:33
such as put patch and delete they all
- 1:36
work in a similar way just conveying a
- 1:38
slightly different message for what you
- 1:39
intend to do on the server and that's
- 1:42
basically the gist of how rest works
- 1:43
from a very high level now let's start
- 1:46
retrieving data from a restful endpoint
- 1:47
using angular for this lesson I'm going
- 1:50
to be working from a stack blitz project
- 1:52
this allows me to include a link in the
- 1:54
description where you can run this code
- 1:55
and fork it for yourself the first thing
- 1:58
we're going to do is go into the app
- 1:59
module and import the HTTP client module


