JS-Applications-HTTP-and-REST-Services
JS-Applications-HTTP-and-REST-Services
SoftUni Team
Technical Trainers
Software University
https://softuni.bg
Table of Contents
1. HTTP Overview
2. HTTP Developer Tools
3. REST and RESTful Services
4. Accessing the GitHub API
5. Popular BaaS Providers
2
Have a Question?
sli.do
#js-advanced
3
HTTP Overview
Hypertext Transfer Protocol
HTTP Basics
HTTP (Hyper Text Transfer Protocol)
Text-based client-server protocol for the Internet
For transferring Web resources (HTML files, images, styles, etc.)
Request-response based
HTTP request
HTTP response
Web Client Web Server
5
HTTP Request Methods
HTTP defines methods to indicate the desired action to be
performed on the identified resource
Method Description
GET Retrieve / load a resource
POST Create / store a resource
PUT Update a resource
DELETE Delete (remove) a resource
PATCH Update resource partially
HEAD Retrieve the resource's headers
10
Content-Type and Disposition
The Content-Type / Content-Disposition headers specify how
the HTTP request / response body should be processed
JSON-encoded data
filename="Financial-Report-April-
11
HTTP Developer Tools
Browser Dev Tools, Postman
Browser Developer Tools
13
Postman
modified/deleted/etc.
Representation 1 Representation 2 Representation 3 Representation 4
16
REST Architectural Constraints
REST defines 6 architectural constraints which make any web
service a true RESTful API
Client-server architecture
Statelessness
Cacheable
Layered system
Code on demand (optional)
Uniform interface
Read more about REST Architectural Constraints
17
REST and RESTful Services – Example
Create a new post
POST http://some-service.org/api/posts
GET http://some-service.org/api/posts/17
Delete existing post
DELETE http://some-service.org/api/posts/17
Replace / modify existing post
PUT/PATCH http://some-service.org/api/posts/17
18
Accessing GitHub Through HTTP
GitHub REST API
GitHub API
List user's all public repositories:
GET https://api.github.com/users/testnakov/repos
GET /repos/testnakov/test-nakov-repo/issues/1
20
Github: Labels Issue
Get the first issue from the "test-nakov-repo" repository
Send a GET request to:
https://api.github.com/repos/testnakov/test-nakov-repo/
issues/:id
Where :id is the current issue
21
GitHub API (2)
Get all labels for certain issue from a public repository:
https://api.github.com/repos/testnakov/test-nakov-repo/issues/1/labels
GET
{"title":"Found a bug",
Body "body": "I'm having a problem with this."}
22
Github: Create Issue
Create an issue when you send a "POST" request
Use your Github account credentials to submit the issue
23
Popular Providers
Back-end as a Service
Back-end as a Service
Web applications require a back-end to store information
User profiles, settings, content, etc.
Creating a back-end can be very time consuming
Ready to use back-end services are available (free trial):
Firebase
Backendless
Back4App
And more
25
Live Demonstration
Firebase Application
Live Demonstration
Backendless Application
Live Demonstration
Back4App Application
Summary
…
HTTP is text-based request-response protocol
…
REST uses GET, POST, PUT, PATCH, DELETE
…
RESTful services address resources by URL
Provide CRUD operations over HTTP
Many BaaS providers have free trials
29
Questions?
© SoftUni – https://about.softuni.bg. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
SoftUni Diamond Partners
Educational Partners
32
Trainings @ Software University (SoftUni)
Software University – High-Quality Education,
Profession and Job for Software Developers
softuni.bg, softuni.org
Software University Foundation
softuni.foundation
Software University @ Facebook
facebook.com/SoftwareUniversity
Software University Forums
forum.softuni.bg
33
License
34