
Join the Conversation!
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
"Please login to view comments"
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
How did you manage to remove the blur property and reach here?
Upgrading gives you access to quizzes so you can test your knowledge, track progress, and improve your skills.
By logging in, you'll unlock full access to this and other free tutorials on JSM Pro.
Why? Logging in lets us personalize your learning experience, track your progress, and keep you in the loop with new workshops, coding tips, and platform updates.
You'll also be the first to know about upcoming launches, events, and exclusive discounts.
No spam—just helpful content to level up your skills.
If that sounds fair, go ahead and log in to continue →
Enter your name and email to get instant access
##Looks like we found a thief monkey By the way, I liked the trick how you reached till here. You have a good sense of humor. You will improve a lot if you join our course with this passion.
var
(function-scoped, outdated)let
(block-scoped, modern and recommended)const
(block-scoped, cannot be reassigned)_
, or $
let let = 5;
is invalid)myVar
and myvar
are different)string
, number
, boolean
, null
, undefined
, bigint
, symbol
Objects
, Arrays
, Functions
Subscribing gives you access to a brief, insightful summary of each lecture to stay on track.
00:00:02 We've talked about protocols, the rules for how clients and servers communicate.
00:00:07 But how does your app actually talk to the backend?
00:00:11 Well, that's where APIs come in.
00:00:14 An API, which stands for Application Programming Interface, is like a restaurant waiter.
00:00:21 You, the client, are hungry and you want to place an order.
00:00:25 The waiter, which is the API, takes your order to the kitchen, and brings back your food.
00:00:31 And then the kitchen, which is the backend, actually prepares your meal, but never interacts with you directly.
00:00:37 And in tech terms, you would be the client, in this case the app or the browser, The waiter would be an API that sends your request to the backend and
00:00:47 returns the response.
00:00:48 And the kitchen would be the actual backend that processes the request and sends back the data.
00:00:54 So for example, when you scroll through Instagram, the app's API fetches new posts from the backend.
00:01:00 And when you check for the weather, the API pulls the data from a weather service.
00:01:05 Without APIs, your app and server wouldn't be able to communicate.
00:01:10 They keep everything in sync.
00:01:12 And APIs follow a specific structure that helps us manage and manipulate resources, be that data or objects that can be created,
00:01:21 read, updated, or deleted.
00:01:24 This is often referred to as CRUD.
00:01:26 So, let's break down the key components.
00:01:29 First, we have HTTP methods or often called verbs.
00:01:34 APIs use HTTP methods to define what kind of action to take on a specific resource.
00:01:40 Let's go back to a restaurant example.
00:01:43 A GET request would retrieve the data from the server, like looking at the menu or fetching the data.
00:01:49 A POST request would create a new resource, like placing an order or adding new data.
00:01:55 A put or a patch call would update an existing resource, like changing your order before it's made, which modifies the data.
00:02:03 And a delete request would remove a resource, like you don't like your food and you cancel your order, which deletes the data.
00:02:11 Alongside these methods, APIs also have endpoints.
00:02:16 An endpoint is a URL that represents a specific resource or action in the backend.
00:02:21 It's like telling the waiter exactly what you want from the menu.
00:02:25 For example, getUsers would return a list of users.
00:02:29 postUsers would create a new user.
00:02:33 putUsersId would update a specific user, and deleteUsersId would delete a specific user.
00:02:40 Later on, we'll dive into the best practices and naming conventions behind API's endpoints.
00:02:45 APIs also have headers, and headers contain extra information, like metadata, about the request or a response, like authentication tokens,
00:02:56 content type, or caching instructions.
00:02:59 Later on, when we develop our great subscription tracking API, we'll use an authorization header that'll include your bearer token that verifies your identity.
00:03:09 Now, let's talk about a request body.
00:03:11 When you use a post or a put request to send the data to the server, the details go into the request body, usually in a JSON format.
00:03:21 So when you're creating a user, you need to pass the info from the frontend form to the backend API in form of a JSON, like a name and an email.
00:03:31 There's also a response body, which contains the data the server sends back after processing that request.
00:03:38 So for example, if you're trying to fetch all the users with the getUsers call, the server might return a JSON that would look something like this.
00:03:47 All API calls also have something known as status code to indicate what just happened.
00:03:53 200 means okay.
00:03:55 201 means that you created something.
00:03:57 400 means that something went wrong and our well-known 404 means that the resource doesn't exist.
00:04:04 Another common one is 500, which is an internal server error saying that something went wrong, but we don't really know what it is.
00:04:12 And if you want to know more about status codes and all related components of APIs or best practices for writing better APIs,
00:04:20 you can check out the complete backend cheat sheet I've created for you.
00:04:24 It's completely free and I'll link it down below this lesson.
00:04:27 But with that in mind, that's how APIs work behind the scenes.
00:04:32 But I know we've covered a lot of stuff, so let me recap.
00:04:35 When you make an HTTP request, here's what happens.
00:04:40 First, the client sends a request to the server using the HTTP protocol.
00:04:46 This request contains the HTTP method, like get or post, the API endpoint, which is the full URL path you're calling, the headers,
00:04:55 which is the metadata, like auth tokens or content types, and finally the body, which is the actual data being sent for post input requests.
00:05:06 After that, the server then processes the request and sends a response that includes a status code, indicating success like 200 or an error,
00:05:16 maybe a 404, as well as the body returned by the server, often in JSON format.
00:05:22 That's it.
00:05:23 That's all that APIs are about and what they're made of.