communication within the browser

Interesting Resources

Wizard Zines by Julia Evans

Fetch API

WebSocket API

fetch API

The browser is able to load static content via http by browsing to a resource, often it is necessary to request additional data with javascript, this is where the fetch API comes into play

Get Data

execute a fetch request with a specific HTTP method

Check if request was successfull (200)

Get the response body as text (also json, arrayBuffer, blob are supported)

Catch block to handle network errors

Post Data

Prepare URL for post request

set http method

set request body

set additional headers to match content

check if request was true

handle network errors

Abort fetch requests

The AbortController offers a nice primitive to enable cancellation and could also be used in your own APIs

Web Socket API

create new web socket connection

Add error callback

Add close callback

Add open callback

Send a message to the server

Add callback for messages

Server Sent Event API

create new event source

listen to messages

listen to custom events