JS-151-API
  • JavaScript Library
  • 02-DOM-Manipulation
    • Overview
    • DOM Explained
    • Example Setup
    • Selecting Elements
    • Events
    • Complete Example
  • 03-API Fundamentals
    • 0-Getting Started
      • Welcome
    • 1-Intro-To-APIs
      • Intro
      • Client
      • Requests
      • JSON
      • API Endpoints
      • Server
      • Response
      • Statelessness
      • REST
    • 2-Asynchronous-Programming
      • Intro
      • Callbacks
      • Promises
      • Promises Continued
      • Chaining Promises
    • 3-Fetch
      • Fetch Intro
      • Star Wars
        • Star Wars API
        • Star Wars Setup
        • Star Wars JS
      • Random Photo
        • Unsplash
        • Unsplash Setup
        • Unsplash JS
    • 4-Apps
      • 01-New York Times
        • 00-App Intro
        • 01-HTML/CSS/API Key
        • 02-Variables
        • 03-Event Listeners
        • 04-fetchResults
          • 01-fetchResults()
          • 02-preventDefault()
          • 03-fetch() method
          • 04-Dates
        • 05-displayResults
          • 01-Logging JSON
          • 02-Working with JSON
          • 03-Link Display
          • 04-Results Navigation
          • 05-Results Update
          • 06-Keywords
          • 07-Images
        • 06-Pagination
          • 01-Pagination Intro
          • 02-Pagination Functions
        • 07-Next Steps
      • 02-YouTube
        • html
        • youtube.css
        • youtube.js
      • 03-GoogleMaps
        • Setup
        • HTML and CSS files
        • API Key
        • JS Setup
        • Adding Your Location
        • Listeners
        • Custom Options
Powered by GitBook
On this page
  • What is a server?
  • Example
  • A Server in Terms of Client/Server Relationship
  1. 03-API Fundamentals
  2. 1-Intro-To-APIs

Server

So we've been talking a lot about clients, but that's only half of the equation. You likely have heard the term "server" before, but let's talk a bit about what it is and how it works.

What is a server?

Let's say you type the url https://www.facebook.com/ into your browser window. From a base level, your browser connected to a Web Server, requested the web page for Facebook, received it from the server, and presented it on your screen.

Unfortunately, nothing can ever be easy. A "server" can mean several different things, depending on its context:

  • The software used to host/deliver web pages

  • The hardware that runs said software

  • Both the software and hardware working in tandem

A server receives a request (such as an HTTP GET) from the client, then returns a response, similar to a container. It can contain a url, an image, some data, something else, or any combination of the above. Sometimes the server will pass a request to a database for more information, then receive that response back before sending it on to the client.

Example

Let's go through a login request as an example. 1. The client sends their username and password to the server 2. The server passes that request along to the database. 3. The database checks to see if it contains that username, and if the password matches what is linked to that username. 4. The database will return either a success or failure response code to the server. 5. The server then passes that that response back to the client, to be displayed in some way on-screen.

A Server in Terms of Client/Server Relationship

For simplification, the server that we are talking about here is where we can send an HTTP request to and get information back from.

PreviousAPI EndpointsNextResponse

Last updated 7 years ago